WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Different Call User Functions
Categories : PHP, Functions, Beginner Guides Click here to Update Your Picture
Ben Yacoub Hatem
Date : Mar 12th 2005
Grade : 2 of 5 (graded 7 times)
Viewed : 5194
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ben Yacoub Hatem
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

PHP allows to call user functions through two different functions shown in the examples below.

A small difference in these 2 examples one has all arguments in an array param the other uses multiple params.
The difference is the function called call_user_func() vs call_user_func_array()

<?php
/* Call User Function with Vars */
function car ($color, $doors) {
    if (
$doors==4 && $color=="blue")
        print
"We have no $color 4 door cars, sorry";
    else
        print
"Our $color 5 door cars are only $9999";
}
call_user_func ('car', "blue", 4) . "\n";
call_user_func ('car', "red", 5);
?>


<?php
/* Call User Function with Array */
function debug($var, $val)
    echo
"***DEBUGGING\nVARIABLE: $var\nVALUE:";
    if (
is_array($val) || is_object($val) || is_resource($val))
       
print_r($val);
    else
        echo
"\n$val\n";
    echo
"***\n";
}

$c = mysql_connect();
$host = $_SERVER["SERVER_NAME"];

call_user_func_array ('debug', array("host", $host));
call_user_func_array ('debug', array("c", $c));
call_user_func_array ('debug', array("_POST", $_POST));
?> 



Basic Authentication with sessions
Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions
Introduction to Language Files
Categories : PHP, Filesystem, Beginner Guides
News management class
Categories : PHP, PHP Classes, Beginner Guides
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
Newbie Notes #8 - A cron trick
Categories : PHP, CURL, Beginner Guides
normalize fields and strings used in where (command's Sql)
Categories : PHP, Databases, Oracle, Functions
a PHP Function to Get only the filename (remove the extension) using regular expressions.
Categories : PHP, Regexps, Beginner Guides
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Beginners Array Functions
Categories : PHP, Beginner Guides, Arrays
Newbie Notes #7 - Ridiculous regex
Categories : PHP, Beginner Guides, Regexps
Newbie Notes #1 - Making a form return to itself
Categories : PHP, Beginner Guides, HTML and PHP