Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

simple php isset problem...?

Featured Replies

Ok, anybody like to suggest why the following:

 

if(isset($_GET['page'])){
	$page = $_GET['page'];
} else {
	$page = 1;
}

echo $page;

 

returns '1' when I go to file.php?page=43

 

But when I do this:

 

if(!isset($_GET['page'])){
	$page = 1;
} else {
	$page = $_GET['page'];
}

echo $page;

 

using the same query, I receive '43'.

That seems to defy logic - isset is returning both true and false with the same input?! Are you absolutely sure it has the same input and you've copied/pasted correctly in each example?

 

On a side note, you'd be better using either is_numeric() or intval() so you can simultaneously check if the value is in fact a positive integer. For example, this pretty much does what you want (I think - I haven't tested it):

 

if(($page = intval($_GET['page'])) <= 0) $page = 1;

Note intval() returns 0 if the argument cannot be parsed to an integer, and this test rules out all non-positive integers too.

  • Author

Yeah I'm positive. I was staring at it for ages but then tested it on my localhost and it worked (as it should). I will change the code to use the functions you mentioned as it is a lot more efficient.

 

Do you recommend I contact my hosts about their PHP?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.