common php questions and answers

  1. What does a special set of tags do in PHP? - The output is displayed directly to the browser.
  2. What’s the difference between include and require? - It’s how they handle failures. If the file is not found by require(), it will 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.

  3. How do you define a constant? - Via define() directive, like define ("MYCONSTANT", 100);

  4. Explain the ternary conditional operator in PHP? - Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.

  5. How do I find out the number of parameters passed into function? - func_num_args() function returns the number of parameters passed in.

  6. What’s the difference between accessing a class method via -> and via ::? - :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization. :: is called as "scope resolution operator".

  7. How do you call a constructor for a parent class? - parent::constructor($value)

  8. What are the two new error levels introduced in PHP5.3? -
    E_DEPRECATED

    The E_DEPRECATED error level is used to indicate that a function or feature has been deprecated.
    E_USER_DEPRECATED

    The E_USER_DEPRECATED level is intended for indicating deprecated features in user code, similarly to the E_USER_ERROR and E_USER_WARNING levels.

0 comments:

Post a Comment

Post your helpful suggestions on this...

 
 
 

typo3 cms templates tutorial

PHP news

php freelancer mumbai India