Interview Questions And Answers

Q: - Apart from the global keyword, is there any way that a function can access and change global variables?

You can also access global variables anywhere in your scripts with a built-in associative array called $GLOBALS. To access a global variable called $test within a function, you could reference it as $GLOBALS['test']

Submitted By:-Martinos             Email-ID: - martinos_sa@rediff.com

Q: - Can you include a function call within a string, as you can with a variable?

No. You must call functions outside quotation marks.

Submitted By:-Martinos            Email-ID: - martinos_sa@rediff.com

Q: - I'm confused by the special variable $this. what is it ?

Within a class, you sometimes need to call the class's methods or access its properties. By combining the $this variable and the -> operator, you can do both. The $this variable is the handle a class is automatically given to refer to itself and to its components.

Submitted By:- Martinos            Email-ID: - martinos_sa@rediff.com

 

1
2