Page 96 - Open Soource Technologies 304.indd
P. 96

Web Technologies-I



                   Notes         $func = ‘foo’;
                                 $func();        // This calls foo()

                                 $func = ‘bar’;
                                 $func(‘test’);  // This calls bar()
                                 $func = ‘echoit’;

                                 $func(‘test’);  // This calls echoit()
                                 ?>
                                 An object method can also be called with the variable functions syntax.
                                        Example: Variable method.

                                 <?php

                                 class Foo
                                 {   function Variable()
                                    {
                                        $name = ‘Bar’;

                                        $this->$name(); // This calls the Bar() method
                                    }

                                       function Bar()
                                    {
                                        echo “This is Bar”;
                                    }

                                 }
                                 $foo = new Foo();
                                 $funcname = “Variable”;

                                 $foo->$funcname();  // This calls $foo->Variable()
                                 ?>

                                 4.7 Category of PHP Functions

                                 This is a list of functions provided by PHP’s built-in extensions, grouped by category. Some
                                 functions fall under more than one header.
                                 Arrays
                                 array, array_count_values, array_diff, array_filter, array_flip, array_intersect, array_keys, array_
                                 map, array_merge,array_merge_recursive, array_multisort, array_pad, array_pop, array_push,
                                 array_rand, array_reduce, array_reverse, array_search,array_shift, array_slice, array_splice,
                                 array_sum, array_unique, array_unshift, array_values, array_walk, arsort, asort, compact,
                                 count,current, each, end, explode, extract, implode, in_array, key, key_exists, krsort, ksort, list,
                                 natcasesort, natsort, next, pos, prev, range,reset, rsort, shuffle, sizeof, sort, uasort, uksort, usort






        90                                LOVELY PROFESSIONAL UNIVERSITY
   91   92   93   94   95   96   97   98   99   100   101