Strings and regular expressions
What will be the answer of the following code snippet?1 | echo 'Testing ' . 1 + 2 . '45' ; |
But the answer is : 245
That is because you can not sum a number with a string. The first part, before the plus mark is a string though there is 1 there.
So engine will simply get it as 0 and the latter part as 245. so answer will be 245.
variable interpolation
Using variable interpolation how we can print the following String?
“I am visiting the php interview questions website”.The word “question” is inside a variable,
$a = ‘question’;
Answer is just,
echo “I am visiting the php interview {$a}s website”;
function return value
What will be the out put of the following code snippet?if(!r())
echo ‘aaa’;
else
echo ‘err’;
function r(){
//return 1;
}
Here you will not get a chance to execute and see what is the out put. So you have to know exactly what will happen here. Probably even if you are a php pro, sometimes you might get confused here.
It will print “aaa”, even though the function do not return anything.
POST and GET Methods
Which will execute faster POST or GET?GET transfer data to the server using URL whereas POST transfer data using form collection which is added to the request by the browser. We can send at most 1024 bytes using URL hence there is upper limit for GET method POST method can transfer large amount of data where upper limit is imposed by web server which is about 2MB data is shown to the user in GET method.
Get is faster but not safe.
0 comments:
Post a Comment