Folks,
In PHP, anything inside single quotes is a string. Right ?
Example 1:
$type = gettype($_GET['page_no']);
if(ISSET($_GET['page_no']) && $type != 'integer')
{
echo '5a. Page Number is not INT!';
}
The above code should be checking for the string 'integer' in the variable value $type. Right ?
So how come it's checking for the value's data type ? I can understand it checking for data type if the string word was inside double quotes.
What is the solution to this mystery ?
QUESTION 2:
Need to check if the value of $type is a number or not.
Look at these 2 examples. On one I use single equal sign while on the other double.
Which one is invalid and why. Answer that. It is important.
And yes, I know the differences between single quotes, double quotes, single equal sign, double equal sign and triple equal sign in PHP.
https://stackoverflow.com/questions/2063480/the-3-different-equals
https://stackoverflow.com/questions/7191626/isset-and-empty-what-to-use
Should not both these following examples be TRUE where one checks if the $type variable has been assigned or not while the other example compares if the $type variable is INT or not ?
In my test, both seem to be showing that $type holds an INT value. Or did I misread the test result ?
Test both exames in your browser and tell me what you figure.
Example 2a:
$type = gettype($_GET['page_no']);
if(ISSET($_GET['page_no']) && $type !== "integer")
{
echo '5b. Page Number is not INT!';
}
Example 2b:
$type = gettype($_GET['page_no']);
if(ISSET($_GET['page_no']) && $type != "integer")
{
echo '5c. Page Number is not INT!';
}
QUESTiON 3:
Back to single quotes again.
Can you tell me what PHP is doing on the first example and what on the second ?
Example 3a:
$type = gettype($_GET['page_no']);
if(ISSET($_GET['page_no']) && $type !== "integer")
{
echo '5b. Page Number is not INT!';
}
Example 3b:
$type = gettype($_GET['page_no']);
if(ISSET($_GET['page_no']) && $type != "integer")
{
echo '5c. Page Number is not INT!';
Kindly provide your answers matching my questions numbers. Will be easy for me to understand your answers.
Thanks