PHP Tutorials

21. How to make one else for two ifs in PHP

By: Marcin : 2012-04-04

Description: Here's something uncommon: How to make one else statement for two nested if conditions? aka: how to make one else for two ifs.


22. All possible substrings in a String in PHP

By: Lukman : 2011-11-17

Description: The following code uses arrays to retrieve all possible substrings in a given string in PHP.


23. call_user_func() or call_user_func_array() functions in PHP

By: Boards : 2011-10-29

Description: Make an array of two entries where the 0th entry is the name of the class to be invoked ('self' and 'parent' work as well) and the 1st entry is the name of the function. Basically, a 'callback' variable is either a string (the name of the function) or an array (0 => 'className', 1 => 'functionName').


24. Anonymous functions as properties in Classes in PHP

By: Schaffhirt A : 2011-10-29

Description: When using anonymous functions as properties in Classes, note that there are three name scopes: one for constants, one for properties and one for methods. That means, you can use the same name for a constant, for a property and for a method at a time.


25. __call() in PHP

By: Rob : 2011-10-29

Description: You can always call protected members using the __call() method - similar to how you hack around this in Ruby using send.


26. use() in PHP

By: Anonymous : 2011-10-29

Description: use() parameters are early binding - they use the variable's value at the point where the lambda function is declared, rather than the point where the lambda function is called (late binding).


27. Return multiple values from a function in PHP

By: Devinemke : 2011-10-28

Description: A function can only return one value, but that value can be an array or other compound value.  If you want to just define several variables into the global scope within your function you can do two things


28. extract() in PHP

By: Dietricha : 2011-10-28

Description: If you compiled with "--enable-track-vars" then an easy way to get variable function args is to use extract()


29. func_get_arg() and func_get_args() functions in PHP

By: Marlin : 2011-10-28

Description: You may pass any number of extra parameters to a function, regardless of the prototyping. In addition, the arguments passed to a function will be available via the variable names defined in the function prototype, as well as via the func_get_arg() and func_get_args() functions.


30. Using class within a function in PHP

By: Albaity : 2011-10-28

Description: To use a PHP class within a function, you need first to load class OUT of the function and then you can use the class functions from your function.