GoConqr has a new look! Let us know what you think.

Flashcards

PHP functions

Ben Parish PHP English 7 cards

Cards in this deck (7)

  1. 1Create a switch statementswitch ($i) {
    case 0:
    echo "i equals 0";
    break;
    case 1:
    echo "i equals 1";
    break;
    }
  2. 2Give examples of intercepter functions (overloading). What are they used for?They are magic methods that can intercept messages sent to undefined methods and properties
    __get( $property )
    Invoked when an undefined property is accessed
    __set( $property, $value )
    Invoked when a value is assigned to an undefined property
    __isset( $property )
    Invoked when isset() is called on an undefined property
    __unset( $property )
    Invoked when unset()is called on an undefined property
    __call( $method, $arg_array )
    Invoked when an undefined non-static method is called
    __callStatic( $method, $arg_array )
    Invoked when an undefined static method is called
  3. 3When is the destruct method invoked?The __destruct() method is invoked whenever an object is removed from memory. This will happen either when you call the unset() function with the object in question or when no further references to the object exist in the process.
  4. 4What is the difference between the include() and require() statements?The handling of errors. A file invoked using require() will bring down your entire process when you meet an error. The same error encountered via a call to include() will merely generate a warning and end execution of the included file, leaving the calling code to continue. This makes require() and require_once() the safe choice for including library files and include() and include_once() useful for operations like templating.
  5. 5What is the difference between autoload() and spl_autoload_register()?spl_autoload_register() supports stacking of more than one custom autoload function.
  6. 6What is the difference between is_callable() and method_exists()?is_callable() is the more sophisticated of the two functions. It accepts an array
    if ( is_callable( array( $product, $method), TRUE ) ) {
    is_callable() optionally accepts a second argument, a Boolean. If you set this to true, the function will only check the syntax of the given method or function name and not its actual existence.
    if ( method_exists( $product, $method ) ) {
    Caution Remember that the fact that a method exists does not mean that it will be callable. method_exists() returns true for private and protected methods as well as for public ones
  7. 7callback function like array_map, array_filter, array_reduce or array_walkhkjklj

Information

Description
PHP (Flashcards) Flashcards on PHP functions, created by Ben Parish on 28/01/2016.
Created by
Ben Parish
Views
1
History
  • Created by Ben Parish · Jan 28, 2016
  • Copied by Ben Parish · Jan 28, 2016
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?