Tag Archives: require and include in php
Interview questions For PHP
Posted on 03. Apr, 2009 by admin.
-
What does a special set of tags <?= and ?> do in PHP?
Its called short tag , in this case the output is directly displayed on the browser without using the echo or print statement.
-
What’s the difference between include and require,include_once and require_once? – In case of include and require it differ in how they handle failures. If the file is not found by require(), it will definatly cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Where as in case of include_once and require_once the basic differnence remain the same as the above mentioned but both have a common feature in which the script or the file is included only once irrespective of how many times a file is included in the program , it definatley fast up the execution where same file is included many times.
- I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem? -
PHP Interpreter treats numbers beginning with 0 as octal. Thats the main reason.
-
Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example? – In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like “{$a},000,000 mln dollars”, then you definitely need to use the braces.
-
How do you define a constant? -
We can do this by define() directive, like
define("ROOT","localhost");and A valid constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. -
How do you pass a variable by value? -
As we do in C++, place an ampersand in front of it, like $a = &$b
-
Will comparison of string “10″ and integer 11 work in PHP? -
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
-
When are you supposed to use endif to end the conditional statement?
When the original if was followed by : and then the code block without braces.

