A function is defined in php by placing the keyword function before the chosen function name.
The function name must not match a pre-defined function and has certain limitation as to the characters that can be part of it. Notably, the function name must not contain any spaces. Following the function name are a parenthesis-enclosed, comma-separated list of variables, these variables are called calling parameters and are helpful if the function must process some values or follows diferent branches depending on external variables. Finally the function body is enclosed in curly brackets { }.
Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>
A simple function call <html> <body> <?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "<br>The button property to call PHP function works"; // Your code here } ?> <input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> /> </body> </head>
The function keyword in PHP allows users to define functions beyond those built into the language, like so: function isFour ($number) { return $number == 4; }Functions in any language, including PHP, allow the developer to re-use their code. Without functions all of the code required to do the simplest of tasks must be re-written constantly; but with functions you must only write the code once and then call it whenever needed.
chdir() PHP function helps in changing the current directory.
It gets options from the command line argument list. It can be used in PHP 4.3 and above, including PHP 5.
You can define a constant using the define() directive.you can use this a number of ways;to define a variable to a constant do:$string = "hello";define("string",$string);to define a string to a constant use:define("hello","there");to define a integer or other numerical value use:define("number",1.0);Summery:to define a string use quotes as you would do a string.Unlike variables in PHP a constant cannot be changed or undefined once it is defined. Constant remains automatically globally throughout the script. It means that it can be accessed from inside a function. e.g.
in php used for one typ website
we cant use set timeout function in php because it is of java script function
Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>
function function_name() { .................... }
The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php
A simple function call <html> <body> <?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "<br>The button property to call PHP function works"; // Your code here } ?> <input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> /> </body> </head>
The function keyword in PHP allows users to define functions beyond those built into the language, like so: function isFour ($number) { return $number == 4; }Functions in any language, including PHP, allow the developer to re-use their code. Without functions all of the code required to do the simplest of tasks must be re-written constantly; but with functions you must only write the code once and then call it whenever needed.
chdir() PHP function helps in changing the current directory.
It gets options from the command line argument list. It can be used in PHP 4.3 and above, including PHP 5.
With a call to the function func_num_args().
header() is a php function used to modify and set HTTP headers sent to the browser.