SlideShare a Scribd company logo
http://programmerblog.net
Introduction to Functions and Arrays
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundamentals: Functions
๏ฌ A set of constructs which allow the programmer to break up their code
into smaller, more manageable, chunks which can be called by name
and which may or may not return a value.
๏ฌ function function_name (parameters) {
function-body
}
๏ฌ function helloWorld(){
echo "HelloWorld"; //No out put is shown
}
By ProgrammerBlog.net http://programmerblog.net/
Functions: Passing Parameters
๏ฌ Passing parameters by value
โ€“ function salestax($price,$tax) {
$total = $price + ($price * $tax
echo "Total cost: $total";
}
salestax(15.00,.075);
$pricetag = 15.00;
$salestax = .075;
salestax($pricetag, $salestax);
By ProgrammerBlog.net http://programmerblog.net/
Functions: Passing Parameters
๏ฌ Passing parameters by reference
$cost = 20.00;
$tax = 0.05;
function calculate_cost(&$cost, $tax)
{
// Modify the $cost variable
$cost = $cost + ($cost * $tax);
// Perform some random change to the $tax variable.
$tax += 4;
}
calculate_cost($cost,$tax);
echo "Tax is: ". $tax*100."<br />";
echo "Cost is: $". $cost."<br />";
By ProgrammerBlog.net http://programmerblog.net/
Functions: Default Argument
Values
๏ฌ Default values are automatically assigned to the argument if no other value is
provided
function salestax($price,$tax=.0575) {
$total = $price + ($price * $tax);
echo "Total cost: $total";
}
$price = 15.47;
salestax($price);
By ProgrammerBlog.net http://programmerblog.net/
Functions: Optional Arguments
๏ฌ Certain arguments can be designated as optional by placing them at the end of
the list and assigning them a default value of nothing .
function salestax($price, $tax="") {
$total = $price + ($price * $tax);
echo "Total cost: $total";
}
salestax(42.00);
function calculate($price,$price2="",$price3="") {
echo $price + $price2 + $price3;
}
calculate(10,"", 3);
By ProgrammerBlog.net http://programmerblog.net/
Functions: Returning Values from
a Function
๏ฌ You can pass data back to the caller by way of the return keyword.
๏ฌ function salestax($price,$tax=.0575) {
$total = $price + ($price * $tax);
return $total;
}
$total = salestax(6.50);
๏ฌ Returning Multiple Values
function retrieve_user_profile() {
$user[] = "Jason";
$user[] = "jason@example.com";
return $user;
}
list($name,$email) = retrieve_user_profile();
echo "Name: $name, email: $email ";
By ProgrammerBlog.net http://programmerblog.net/
Functions: Nesting Functions
๏ฌ defining and invoking functions within functions
function salestax($price,$tax)
function convert_pound($dollars, $conversion=1.6) {
return $dollars * $conversion;
}
$total = $price + ($price * $tax);
echo "Total cost in dollars: $total. Cost in British pounds: "
. convert_pound($total);
}
salestax(15.00,.075);
echo convert_pound(15);
By ProgrammerBlog.net http://programmerblog.net/
Functions: Recursive Functions
functions that call themselves
function nfact($n) {
if ($n == 0) {
return 1;
}else {
return $n * nfact($n - 1);
}
}
//call to function
nfact($num) ;
By ProgrammerBlog.net http://programmerblog.net/
Functions: Variable Functions
๏ฌ Functions with parameters on run time
function hello(){
if (func_num_args()>0){
$arg=func_get_arg(0); //Thefirstargumentisatposition0
echo "Hello$arg";
} else {
echo "HelloWorld";
}
}
hello("Reader"); //Displays"HelloReader"
hello(); //Displays"HelloWorld"
By ProgrammerBlog.net http://programmerblog.net/
Server Side Includes (SSI):
include() function
๏ฌ Include function
๏ฌ You can insert the content of one PHP file into another PHP file before the server
executes it, with the include() or require() function. (e.g. Header, Menu, footer)
๏ฌ The include() function takes all the content in a specified file and includes it in the
current file
๏ฌ include() generates a warning, but the script will continue execution
<html>
<body>
<?php include("header.php"); ?>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
</body>
</html>
By ProgrammerBlog.net http://programmerblog.net/
Server Side Includes (SSI):
include() function
๏ฌ <html>
<body>
<div class="leftmenu">
<?php include("menu.php"); ?>
</div>
<h1>Welcome to my home page.</h1>
<p>Some text.</p>
</body>
</html>
By ProgrammerBlog.net http://programmerblog.net/
Server Side Includes (SSI):
include() function
<html>
<body>
<div class="leftmenu">
<a href="/default.php">Home</a>
<a href="/tutorials.php">Tutorials</a>
<a href="/references.php">References</a>
<a href="/examples.php">Examples</a>
<a href="/about.php">About Us</a>
<a href="/contact.php">Contact Us</a>
</div>
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
</body>
</html>
By ProgrammerBlog.net http://programmerblog.net/
Server Side Includes (SSI):
require() function
๏ฌ Require function
require() generates a fatal error, and the script will stop
include() generates a warning, but the script will continue execution
<html>
<body>
<?php
require("wrongFile.php");
echo "Hello World!";
?>
</body>
</html>
๏ฌ It is recommended to use the require() function instead of include(), because
scripts should not continue after an error.
By ProgrammerBlog.net http://programmerblog.net/
PHP Built In Functions
๏ฌ Math functions
๏ฌ http://www.w3schools.com/php/php_ref_math.asp
โ€“ pi() Returns the value of PI
โ€“ pow() Returns the value of x to the power of y
โ€“ rad2deg() Converts a radian number to a degree
โ€“ rand() Returns a random integer
โ€“ round() Rounds a number to the nearest integer
โ€“ sin() Returns the sine of a number
โ€“ sinh() Returns the hyperbolic sine of a number
โ€“ sqrt() Returns the square root of a number
โ€“ srand() Seeds the random number generator
โ€“ tan() Returns the tangent of an angle
โ€“ tanh()
โ€“ abs() Returns the absolute value of a number
By ProgrammerBlog.net http://programmerblog.net/
PHP Built In Misc. Functions
๏ฌ Constants
โ€“ M_LN10 Returns the natural logarithm of 10 (approx. 2.302)
โ€“ M_PI Returns PI (approx. 3.14159)
โ€“ M_SQRT2 Returns the square root of 2 (approx. 1.414)
๏ฌ Miscellaneous Functions
โ€“ Strlen Returns length of a string
โ€“ count() Returns the count of an array.
โ€“ Strtolower strtolower() to lower case.
โ€“ strtoupper() strtoupper() convert string to upper case
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments - Arrays
๏ฌ Arrays are ordered collections of items, called elements
๏ฌ Each element has a value, and is identified by a key that is unique to the array It
belongs to
๏ฌ In PHP, there are three kind of arrays:
โ€“ Numeric array - An array with a numeric index
โ€“ Associative array - An array where each ID key is associated with a value
โ€“ Multidimensional array - An array containing one or more arrays.
โ€“ $a = array();
โ€“ $state[0] = "Delaware";
โ€“ $a = array (10, 20, 30);
โ€“ $a = array (โ€™aโ€™ => 10, โ€™bโ€™ => 20, โ€™ceeโ€™ => 30);
โ€“ $a = array (5 => 1, 3 => 2, 1 => 3,);
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments - Arrays
๏ฌ Numeric Arrays:
โ€“ A numeric array stores each array element with a numeric index.
โ€“ $cars = array("Saab","Volvo","BMW","Toyota");
โ€“ $cars[0]="Saab"; //2nd
way of declaring arrays
โ€“ $cars[1]="Volvo";
โ€“ $cars[2]="BMW";
โ€“ $cars[3]="Toyota";
โ€“ echo $cars[0] . " and " . $cars[1] . " are Swedish cars.";
๏ฌ Associative Arrays
โ€“ An associative array, each ID key is associated with a value.
โ€“ $ages = array(ยซJohn"=>32, ยซJane"=>30, ยซDavid"=>34);
โ€“ $ages[โ€˜John '] = "32";
โ€“ $ages[โ€˜Jane '] = "30";
โ€“ $ages[โ€˜David '] = "34";
โ€“ $states = array (0 => "Alabama", "1" => "Alaska"..."49" => "Wyoming"); //numeric
โ€“ $states = array ("OH" => "Ohio", "PA" => "Pennsylvania", "NY" => "New York")
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments - Arrays
๏ฌ Multidimensional Arrays
๏ฌ Arrays of arrays, known as multidimensional arrays
๏ฌ In a multidimensional array, each element in the main array can also be an array.
๏ฌ $cars = array ( โ€œToyota"=>array ( โ€œCorollaโ€œ, " Camryโ€œ, "Toyota 4Runnerโ€ ),
โ€œSuzuki"=>array ( โ€œVitaraโ€ ),
โ€œHonda"=>array ( "Accordโ€œ, โ€œSedanโ€œ, โ€œOdysseyโ€ ) );
๏ฌ echo "Is " . $ cars [Toyota '][2] . " a member of the Toyota cars?โ€œ;
๏ฌ Is Toyota 4Runner a member of the Toyota cars?
๏ฌ $states = array (
"Ohio" => array ("population" => "11,353,140", "capital" => "Columbus"),
"Nebraska" => array ("population" => "1,711,263", "capital" => "Omaha")
)
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments โ€“ Printing Arrays
๏ฌ print_r() and var_dump()
๏ฌ var_dump
โ€“ var_dump() outputs the data types of each value
โ€“ var_dump() is capable of outputting the value of more than one variable
โ€“ var_dump($states);
โ€“ $a = array (1, 2, 3);
โ€“ $b = array (โ€™aโ€™ => 1, โ€™bโ€™ => 2, โ€™cโ€™ => 3);
โ€“ var_dump ($a + $b); // creates union of arrays
โ€“ If 2 arrays have common elements and also share same string or numeric key will
appearance in result or output
๏ฌ print_r
โ€“ print_r can return its output as a string, as opposed to writing it to the scriptโ€™s standard
output
โ€“ print_r($states);
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments โ€“ Comparing -
Counting Arrays
๏ฌ $a = array (1, 2, 3);
$b = array (1 => 2, 2 => 3, 0 => 1);
$c = array (โ€™aโ€™ => 1, โ€™bโ€™ => 2, โ€™cโ€™ => 3);
var_dump ($a == $b); // True
var_dump ($a === $b); // False returns true only if the array contains the
same key/value pairs in the same order
var_dump ($a == $c); // True
var_dump ($a === $c); // False
๏ฌ $a = array (1, 2, 4);
๏ฌ $b = array();
๏ฌ $c = 10;
๏ฌ echo count ($a); // Outputs 3
๏ฌ echo count ($b); // Outputs 0
๏ฌ echo count ($c); // Outputs 1
๏ฌ is_array() function : echo in_array ($a, 2); // True
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments โ€“ Flipping and
Reversing , Range
๏ฌ array_flip()
โ€“ Exchanges all keys with their associated values in an array
$trans = array("a" => 1, "b" => 1, "c" => 2);
$trans = array_flip($trans);
print_r($trans);
โ€“ Output = Array ( [1] => b [2] => c )
๏ฌ array_reverse()
โ€“ Return an array with elements in reverse order
๏ฌ array_values()
โ€“ array_values โ€” Return all the values of an array
โ€“ $array = array("size" => "XL", "color" => "gold");
print_r(array_values($array));
โ€“ array_keys โ€” Return all the keys of an array
๏ฌ range()
โ€“ The range() function provides an easy way to quickly create and fill an array consisting
of a range of low and high integer values.
โ€“ $die = range(0,6); // Same as specifying $die = array(0,1,2,3,4,5,6)
By ProgrammerBlog.net http://programmerblog.net/By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments โ€“ Sorting Arrays
๏ฌ There are many functions in PHP core that provide various methods of sorting
array contents.
๏ฌ sort
โ€“ $array = array(โ€™aโ€™ => โ€™fooโ€™, โ€™bโ€™ => โ€™barโ€™, โ€™cโ€™ => โ€™bazโ€™);
sort($array);
var_dump($array);
๏ฌ asort //to maintain key association,
- $array = array(โ€™aโ€™ => โ€™fooโ€™, โ€™bโ€™ => โ€™barโ€™, โ€™cโ€™ => โ€™bazโ€™);
asort($array);
var_dump($array);
๏ฌ rsort,
๏ฌ arsort // sorting an array in descending order
By ProgrammerBlog.net http://programmerblog.net/
PHP Fundaments โ€“ Arrays as Stack
and Queues
๏ฌ Stack Last in First Out.
๏ฌ array_push()
โ€“ $stack = array();
array_push($stack, โ€™barโ€™, โ€™bazโ€™);
var_dump($stack);
๏ฌ array_pop()
โ€“ $states = array("Ohio","New York","California","Texas");
โ€“ $state = array_pop($states); // $state = "Texas"
๏ฌ Queues
๏ฌ array_shift, Shift an element off the beginning of array
๏ฌ array_unshift - Prepend one or more elements to the beginning of an array
$stack = array(โ€™quxโ€™, โ€™barโ€™, โ€™bazโ€™);
$first_element = array_shift($stack);
var_dump($stack);
array_unshift($stack, โ€™fooโ€™);
var_dump($stack);
By ProgrammerBlog.net http://programmerblog.net/
Super Globals
๏ฌ Several predefined variables in PHP are "superglobals", which means
they are available in all scopes throughout a script. There is no need to
do global $variable; to access them within functions or methods.
๏ฌ $GLOBALS
๏ฌ $_SERVER
๏ฌ $_GET
๏ฌ $_POST
๏ฌ $_FILES
๏ฌ $_COOKIE
๏ฌ $_SESSION
๏ฌ $_REQUEST
๏ฌ $_ENV
By ProgrammerBlog.net http://programmerblog.net/
Features โ€“ Super Globals
๏ฌ $GLOBALS โ€” References all variables available in global scope
๏ฌ <?php
function test() {
$foo = "local variable";
echo '$foo in global scope: ' . $GLOBALS["foo"] . "n";
echo '$foo in current scope: ' . $foo . "n";
}
$foo = "Example content";
test();
?>
๏ฌ $_SERVER -- $HTTP_SERVER_VARS [deprecated] โ€” Server and execution environment
information
๏ฌ <?php
echo $_SERVER['SERVER_NAME'];
?>
By ProgrammerBlog.net http://programmerblog.net/
Super Globals
๏ฌ $_ENV -- $HTTP_ENV_VARS [deprecated] โ€” Environment variables
๏ฌ <?php
echo 'My username is ' .$_ENV["USER"] . '!';
?>
๏ฌ $ip = $_SERVER['REMOTE_ADDR'];
By ProgrammerBlog.net http://programmerblog.net/
Super Globals
๏ฌ Thank you for viewing this slide. Hope this is helpful for you.
๏ฌ please visit our blog
http://programmerblog.net
Follow us on twitter
https://twitter.com/progblogdotnet
By ProgrammerBlog.net http://programmerblog.net/
Ad

More Related Content

What's hot (20)

Php
PhpPhp
Php
Rajkiran Mummadi
ย 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
ย 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
ย 
02 Php Vars Op Control Etc
02 Php Vars Op Control Etc02 Php Vars Op Control Etc
02 Php Vars Op Control Etc
Geshan Manandhar
ย 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
Ashish Chamoli
ย 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
ย 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
Mark Baker
ย 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
ย 
php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in function
tumetr1
ย 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
Bradley Holt
ย 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
Muthuganesh S
ย 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
ย 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
Ayesh Karunaratne
ย 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
Denis Ristic
ย 
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™PhinneyAnonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Hipot Studio
ย 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
ย 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
Bozhidar Boshnakov
ย 
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
Hisateru Tanaka
ย 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
ย 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
ย 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
ย 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
ย 
02 Php Vars Op Control Etc
02 Php Vars Op Control Etc02 Php Vars Op Control Etc
02 Php Vars Op Control Etc
Geshan Manandhar
ย 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
Ashish Chamoli
ย 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
ย 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
Mark Baker
ย 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
ย 
php 2 Function creating, calling, PHP built-in function
php 2 Function creating, calling,PHP built-in functionphp 2 Function creating, calling,PHP built-in function
php 2 Function creating, calling, PHP built-in function
tumetr1
ย 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
Bradley Holt
ย 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
Ian Macali
ย 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
Ayesh Karunaratne
ย 
07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards07 Introduction to PHP #burningkeyboards
07 Introduction to PHP #burningkeyboards
Denis Ristic
ย 
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™PhinneyAnonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Anonymous Functions in PHP 5.3 - Matthew Weier Oโ€™Phinney
Hipot Studio
ย 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
ย 
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
้–ข่ฅฟPHPๅ‹‰ๅผทไผš php5.4ใคใพใฟใใ„
Hisateru Tanaka
ย 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
ย 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
ย 

Viewers also liked (14)

[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
Thai Pham
ย 
Magento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPMagento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHP
varien
ย 
01 sistem bilangan real
01 sistem bilangan real01 sistem bilangan real
01 sistem bilangan real
sri puji lestari
ย 
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
releaseey
ย 
Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)
Ivo Jansch
ย 
Terrorism
TerrorismTerrorism
Terrorism
Tej Surya
ย 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
Ivo Jansch
ย 
telecom
telecomtelecom
telecom
AJU P.T
ย 
Autoankauf
AutoankaufAutoankauf
Autoankauf
Kรถln Autoankauf
ย 
Audacity
AudacityAudacity
Audacity
Cherese Collins
ย 
KRC Summer Intern Slideshow!
KRC Summer Intern Slideshow!KRC Summer Intern Slideshow!
KRC Summer Intern Slideshow!
janikim
ย 
St web pages & booklet
St web pages & bookletSt web pages & booklet
St web pages & booklet
SoundsTogether
ย 
Trek Miles
Trek MilesTrek Miles
Trek Miles
David Benoy
ย 
[Php] navigations
[Php] navigations[Php] navigations
[Php] navigations
Thai Pham
ย 
Magento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPMagento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHP
varien
ย 
01 sistem bilangan real
01 sistem bilangan real01 sistem bilangan real
01 sistem bilangan real
sri puji lestari
ย 
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
่กŒๆ”ฟ้™ข็ฐกๅ ฑ ๆ€งๅนณ่™•๏ผšๆˆ‘ๅœ‹ๆ€งๅˆฅๅนณ็ญ‰ๆŽจๅ‹•ๆˆๆžœๅŠๆœชไพ†ๅฑ•ๆœ›(ๆ‡ถไบบๅŒ…)
releaseey
ย 
Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)Enterprise PHP (PHP London Conference 2008)
Enterprise PHP (PHP London Conference 2008)
Ivo Jansch
ย 
Terrorism
TerrorismTerrorism
Terrorism
Tej Surya
ย 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
Ivo Jansch
ย 
telecom
telecomtelecom
telecom
AJU P.T
ย 
KRC Summer Intern Slideshow!
KRC Summer Intern Slideshow!KRC Summer Intern Slideshow!
KRC Summer Intern Slideshow!
janikim
ย 
St web pages & booklet
St web pages & bookletSt web pages & booklet
St web pages & booklet
SoundsTogether
ย 
Trek Miles
Trek MilesTrek Miles
Trek Miles
David Benoy
ย 
Ad

Similar to Php my sql - functions - arrays - tutorial - programmerblog.net (20)

Chapter 2 wbp.pptx
Chapter 2 wbp.pptxChapter 2 wbp.pptx
Chapter 2 wbp.pptx
40NehaPagariya
ย 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
AbhishekSharma2958
ย 
php AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdfphp AND MYSQL _ppt.pdf
php AND MYSQL _ppt.pdf
SVN Polytechnic Kalan Sultanpur UP
ย 
Arrays in php
Arrays in phpArrays in php
Arrays in php
Laiby Thomas
ย 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
ย 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
ย 
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
ย 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26
SynapseindiaComplaints
ย 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
Henry Osborne
ย 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python Developers
Carlos Vences
ย 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
ย 
Php Syntax Basics in one single course in nutshell
Php Syntax Basics in one single course in nutshellPhp Syntax Basics in one single course in nutshell
Php Syntax Basics in one single course in nutshell
binzbinz3
ย 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
ย 
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Dhivyaa C.R
ย 
UNIT IV (4).pptx
UNIT IV (4).pptxUNIT IV (4).pptx
UNIT IV (4).pptx
DrDhivyaaCRAssistant
ย 
PHP Array Functions.pptx
PHP Array Functions.pptxPHP Array Functions.pptx
PHP Array Functions.pptx
KirenKinu
ย 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
Divante
ย 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
ย 
07-PHP.pptx
07-PHP.pptx07-PHP.pptx
07-PHP.pptx
GiyaShefin
ย 
07-PHP.pptx
07-PHP.pptx07-PHP.pptx
07-PHP.pptx
ShishirKantSingh1
ย 
Chapter 2 wbp.pptx
Chapter 2 wbp.pptxChapter 2 wbp.pptx
Chapter 2 wbp.pptx
40NehaPagariya
ย 
Arrays in php
Arrays in phpArrays in php
Arrays in php
Laiby Thomas
ย 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
ย 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
outcast96
ย 
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptxPHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
PHPneweeeeeeeeeeeeeeeeeeeeeeeeeeeeee.pptx
kamalsmail1
ย 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26
SynapseindiaComplaints
ย 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
Henry Osborne
ย 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python Developers
Carlos Vences
ย 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
ย 
Php Syntax Basics in one single course in nutshell
Php Syntax Basics in one single course in nutshellPhp Syntax Basics in one single course in nutshell
Php Syntax Basics in one single course in nutshell
binzbinz3
ย 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
ย 
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Dhivyaa C.R
ย 
PHP Array Functions.pptx
PHP Array Functions.pptxPHP Array Functions.pptx
PHP Array Functions.pptx
KirenKinu
ย 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
Divante
ย 
Web Technology_10.ppt
Web Technology_10.pptWeb Technology_10.ppt
Web Technology_10.ppt
Aftabali702240
ย 
07-PHP.pptx
07-PHP.pptx07-PHP.pptx
07-PHP.pptx
GiyaShefin
ย 
Ad

Recently uploaded (20)

Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
ย 
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy ConsumptionDrupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Drupalcamp Finland โ€“ Measuring Front-end Energy Consumption
Exove
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
ย 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
ย 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
ย 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
ย 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 

Php my sql - functions - arrays - tutorial - programmerblog.net

  • 1. http://programmerblog.net Introduction to Functions and Arrays By ProgrammerBlog.net http://programmerblog.net/
  • 2. PHP Fundamentals: Functions ๏ฌ A set of constructs which allow the programmer to break up their code into smaller, more manageable, chunks which can be called by name and which may or may not return a value. ๏ฌ function function_name (parameters) { function-body } ๏ฌ function helloWorld(){ echo "HelloWorld"; //No out put is shown } By ProgrammerBlog.net http://programmerblog.net/
  • 3. Functions: Passing Parameters ๏ฌ Passing parameters by value โ€“ function salestax($price,$tax) { $total = $price + ($price * $tax echo "Total cost: $total"; } salestax(15.00,.075); $pricetag = 15.00; $salestax = .075; salestax($pricetag, $salestax); By ProgrammerBlog.net http://programmerblog.net/
  • 4. Functions: Passing Parameters ๏ฌ Passing parameters by reference $cost = 20.00; $tax = 0.05; function calculate_cost(&$cost, $tax) { // Modify the $cost variable $cost = $cost + ($cost * $tax); // Perform some random change to the $tax variable. $tax += 4; } calculate_cost($cost,$tax); echo "Tax is: ". $tax*100."<br />"; echo "Cost is: $". $cost."<br />"; By ProgrammerBlog.net http://programmerblog.net/
  • 5. Functions: Default Argument Values ๏ฌ Default values are automatically assigned to the argument if no other value is provided function salestax($price,$tax=.0575) { $total = $price + ($price * $tax); echo "Total cost: $total"; } $price = 15.47; salestax($price); By ProgrammerBlog.net http://programmerblog.net/
  • 6. Functions: Optional Arguments ๏ฌ Certain arguments can be designated as optional by placing them at the end of the list and assigning them a default value of nothing . function salestax($price, $tax="") { $total = $price + ($price * $tax); echo "Total cost: $total"; } salestax(42.00); function calculate($price,$price2="",$price3="") { echo $price + $price2 + $price3; } calculate(10,"", 3); By ProgrammerBlog.net http://programmerblog.net/
  • 7. Functions: Returning Values from a Function ๏ฌ You can pass data back to the caller by way of the return keyword. ๏ฌ function salestax($price,$tax=.0575) { $total = $price + ($price * $tax); return $total; } $total = salestax(6.50); ๏ฌ Returning Multiple Values function retrieve_user_profile() { $user[] = "Jason"; $user[] = "[email protected]"; return $user; } list($name,$email) = retrieve_user_profile(); echo "Name: $name, email: $email "; By ProgrammerBlog.net http://programmerblog.net/
  • 8. Functions: Nesting Functions ๏ฌ defining and invoking functions within functions function salestax($price,$tax) function convert_pound($dollars, $conversion=1.6) { return $dollars * $conversion; } $total = $price + ($price * $tax); echo "Total cost in dollars: $total. Cost in British pounds: " . convert_pound($total); } salestax(15.00,.075); echo convert_pound(15); By ProgrammerBlog.net http://programmerblog.net/
  • 9. Functions: Recursive Functions functions that call themselves function nfact($n) { if ($n == 0) { return 1; }else { return $n * nfact($n - 1); } } //call to function nfact($num) ; By ProgrammerBlog.net http://programmerblog.net/
  • 10. Functions: Variable Functions ๏ฌ Functions with parameters on run time function hello(){ if (func_num_args()>0){ $arg=func_get_arg(0); //Thefirstargumentisatposition0 echo "Hello$arg"; } else { echo "HelloWorld"; } } hello("Reader"); //Displays"HelloReader" hello(); //Displays"HelloWorld" By ProgrammerBlog.net http://programmerblog.net/
  • 11. Server Side Includes (SSI): include() function ๏ฌ Include function ๏ฌ You can insert the content of one PHP file into another PHP file before the server executes it, with the include() or require() function. (e.g. Header, Menu, footer) ๏ฌ The include() function takes all the content in a specified file and includes it in the current file ๏ฌ include() generates a warning, but the script will continue execution <html> <body> <?php include("header.php"); ?> <h1>Welcome to my home page!</h1> <p>Some text.</p> </body> </html> By ProgrammerBlog.net http://programmerblog.net/
  • 12. Server Side Includes (SSI): include() function ๏ฌ <html> <body> <div class="leftmenu"> <?php include("menu.php"); ?> </div> <h1>Welcome to my home page.</h1> <p>Some text.</p> </body> </html> By ProgrammerBlog.net http://programmerblog.net/
  • 13. Server Side Includes (SSI): include() function <html> <body> <div class="leftmenu"> <a href="/default.php">Home</a> <a href="/tutorials.php">Tutorials</a> <a href="/references.php">References</a> <a href="/examples.php">Examples</a> <a href="/about.php">About Us</a> <a href="/contact.php">Contact Us</a> </div> <h1>Welcome to my home page!</h1> <p>Some text.</p> </body> </html> By ProgrammerBlog.net http://programmerblog.net/
  • 14. Server Side Includes (SSI): require() function ๏ฌ Require function require() generates a fatal error, and the script will stop include() generates a warning, but the script will continue execution <html> <body> <?php require("wrongFile.php"); echo "Hello World!"; ?> </body> </html> ๏ฌ It is recommended to use the require() function instead of include(), because scripts should not continue after an error. By ProgrammerBlog.net http://programmerblog.net/
  • 15. PHP Built In Functions ๏ฌ Math functions ๏ฌ http://www.w3schools.com/php/php_ref_math.asp โ€“ pi() Returns the value of PI โ€“ pow() Returns the value of x to the power of y โ€“ rad2deg() Converts a radian number to a degree โ€“ rand() Returns a random integer โ€“ round() Rounds a number to the nearest integer โ€“ sin() Returns the sine of a number โ€“ sinh() Returns the hyperbolic sine of a number โ€“ sqrt() Returns the square root of a number โ€“ srand() Seeds the random number generator โ€“ tan() Returns the tangent of an angle โ€“ tanh() โ€“ abs() Returns the absolute value of a number By ProgrammerBlog.net http://programmerblog.net/
  • 16. PHP Built In Misc. Functions ๏ฌ Constants โ€“ M_LN10 Returns the natural logarithm of 10 (approx. 2.302) โ€“ M_PI Returns PI (approx. 3.14159) โ€“ M_SQRT2 Returns the square root of 2 (approx. 1.414) ๏ฌ Miscellaneous Functions โ€“ Strlen Returns length of a string โ€“ count() Returns the count of an array. โ€“ Strtolower strtolower() to lower case. โ€“ strtoupper() strtoupper() convert string to upper case By ProgrammerBlog.net http://programmerblog.net/
  • 17. PHP Fundaments - Arrays ๏ฌ Arrays are ordered collections of items, called elements ๏ฌ Each element has a value, and is identified by a key that is unique to the array It belongs to ๏ฌ In PHP, there are three kind of arrays: โ€“ Numeric array - An array with a numeric index โ€“ Associative array - An array where each ID key is associated with a value โ€“ Multidimensional array - An array containing one or more arrays. โ€“ $a = array(); โ€“ $state[0] = "Delaware"; โ€“ $a = array (10, 20, 30); โ€“ $a = array (โ€™aโ€™ => 10, โ€™bโ€™ => 20, โ€™ceeโ€™ => 30); โ€“ $a = array (5 => 1, 3 => 2, 1 => 3,); By ProgrammerBlog.net http://programmerblog.net/
  • 18. PHP Fundaments - Arrays ๏ฌ Numeric Arrays: โ€“ A numeric array stores each array element with a numeric index. โ€“ $cars = array("Saab","Volvo","BMW","Toyota"); โ€“ $cars[0]="Saab"; //2nd way of declaring arrays โ€“ $cars[1]="Volvo"; โ€“ $cars[2]="BMW"; โ€“ $cars[3]="Toyota"; โ€“ echo $cars[0] . " and " . $cars[1] . " are Swedish cars."; ๏ฌ Associative Arrays โ€“ An associative array, each ID key is associated with a value. โ€“ $ages = array(ยซJohn"=>32, ยซJane"=>30, ยซDavid"=>34); โ€“ $ages[โ€˜John '] = "32"; โ€“ $ages[โ€˜Jane '] = "30"; โ€“ $ages[โ€˜David '] = "34"; โ€“ $states = array (0 => "Alabama", "1" => "Alaska"..."49" => "Wyoming"); //numeric โ€“ $states = array ("OH" => "Ohio", "PA" => "Pennsylvania", "NY" => "New York") By ProgrammerBlog.net http://programmerblog.net/
  • 19. PHP Fundaments - Arrays ๏ฌ Multidimensional Arrays ๏ฌ Arrays of arrays, known as multidimensional arrays ๏ฌ In a multidimensional array, each element in the main array can also be an array. ๏ฌ $cars = array ( โ€œToyota"=>array ( โ€œCorollaโ€œ, " Camryโ€œ, "Toyota 4Runnerโ€ ), โ€œSuzuki"=>array ( โ€œVitaraโ€ ), โ€œHonda"=>array ( "Accordโ€œ, โ€œSedanโ€œ, โ€œOdysseyโ€ ) ); ๏ฌ echo "Is " . $ cars [Toyota '][2] . " a member of the Toyota cars?โ€œ; ๏ฌ Is Toyota 4Runner a member of the Toyota cars? ๏ฌ $states = array ( "Ohio" => array ("population" => "11,353,140", "capital" => "Columbus"), "Nebraska" => array ("population" => "1,711,263", "capital" => "Omaha") ) By ProgrammerBlog.net http://programmerblog.net/
  • 20. PHP Fundaments โ€“ Printing Arrays ๏ฌ print_r() and var_dump() ๏ฌ var_dump โ€“ var_dump() outputs the data types of each value โ€“ var_dump() is capable of outputting the value of more than one variable โ€“ var_dump($states); โ€“ $a = array (1, 2, 3); โ€“ $b = array (โ€™aโ€™ => 1, โ€™bโ€™ => 2, โ€™cโ€™ => 3); โ€“ var_dump ($a + $b); // creates union of arrays โ€“ If 2 arrays have common elements and also share same string or numeric key will appearance in result or output ๏ฌ print_r โ€“ print_r can return its output as a string, as opposed to writing it to the scriptโ€™s standard output โ€“ print_r($states); By ProgrammerBlog.net http://programmerblog.net/
  • 21. PHP Fundaments โ€“ Comparing - Counting Arrays ๏ฌ $a = array (1, 2, 3); $b = array (1 => 2, 2 => 3, 0 => 1); $c = array (โ€™aโ€™ => 1, โ€™bโ€™ => 2, โ€™cโ€™ => 3); var_dump ($a == $b); // True var_dump ($a === $b); // False returns true only if the array contains the same key/value pairs in the same order var_dump ($a == $c); // True var_dump ($a === $c); // False ๏ฌ $a = array (1, 2, 4); ๏ฌ $b = array(); ๏ฌ $c = 10; ๏ฌ echo count ($a); // Outputs 3 ๏ฌ echo count ($b); // Outputs 0 ๏ฌ echo count ($c); // Outputs 1 ๏ฌ is_array() function : echo in_array ($a, 2); // True By ProgrammerBlog.net http://programmerblog.net/
  • 22. PHP Fundaments โ€“ Flipping and Reversing , Range ๏ฌ array_flip() โ€“ Exchanges all keys with their associated values in an array $trans = array("a" => 1, "b" => 1, "c" => 2); $trans = array_flip($trans); print_r($trans); โ€“ Output = Array ( [1] => b [2] => c ) ๏ฌ array_reverse() โ€“ Return an array with elements in reverse order ๏ฌ array_values() โ€“ array_values โ€” Return all the values of an array โ€“ $array = array("size" => "XL", "color" => "gold"); print_r(array_values($array)); โ€“ array_keys โ€” Return all the keys of an array ๏ฌ range() โ€“ The range() function provides an easy way to quickly create and fill an array consisting of a range of low and high integer values. โ€“ $die = range(0,6); // Same as specifying $die = array(0,1,2,3,4,5,6) By ProgrammerBlog.net http://programmerblog.net/By ProgrammerBlog.net http://programmerblog.net/
  • 23. PHP Fundaments โ€“ Sorting Arrays ๏ฌ There are many functions in PHP core that provide various methods of sorting array contents. ๏ฌ sort โ€“ $array = array(โ€™aโ€™ => โ€™fooโ€™, โ€™bโ€™ => โ€™barโ€™, โ€™cโ€™ => โ€™bazโ€™); sort($array); var_dump($array); ๏ฌ asort //to maintain key association, - $array = array(โ€™aโ€™ => โ€™fooโ€™, โ€™bโ€™ => โ€™barโ€™, โ€™cโ€™ => โ€™bazโ€™); asort($array); var_dump($array); ๏ฌ rsort, ๏ฌ arsort // sorting an array in descending order By ProgrammerBlog.net http://programmerblog.net/
  • 24. PHP Fundaments โ€“ Arrays as Stack and Queues ๏ฌ Stack Last in First Out. ๏ฌ array_push() โ€“ $stack = array(); array_push($stack, โ€™barโ€™, โ€™bazโ€™); var_dump($stack); ๏ฌ array_pop() โ€“ $states = array("Ohio","New York","California","Texas"); โ€“ $state = array_pop($states); // $state = "Texas" ๏ฌ Queues ๏ฌ array_shift, Shift an element off the beginning of array ๏ฌ array_unshift - Prepend one or more elements to the beginning of an array $stack = array(โ€™quxโ€™, โ€™barโ€™, โ€™bazโ€™); $first_element = array_shift($stack); var_dump($stack); array_unshift($stack, โ€™fooโ€™); var_dump($stack); By ProgrammerBlog.net http://programmerblog.net/
  • 25. Super Globals ๏ฌ Several predefined variables in PHP are "superglobals", which means they are available in all scopes throughout a script. There is no need to do global $variable; to access them within functions or methods. ๏ฌ $GLOBALS ๏ฌ $_SERVER ๏ฌ $_GET ๏ฌ $_POST ๏ฌ $_FILES ๏ฌ $_COOKIE ๏ฌ $_SESSION ๏ฌ $_REQUEST ๏ฌ $_ENV By ProgrammerBlog.net http://programmerblog.net/
  • 26. Features โ€“ Super Globals ๏ฌ $GLOBALS โ€” References all variables available in global scope ๏ฌ <?php function test() { $foo = "local variable"; echo '$foo in global scope: ' . $GLOBALS["foo"] . "n"; echo '$foo in current scope: ' . $foo . "n"; } $foo = "Example content"; test(); ?> ๏ฌ $_SERVER -- $HTTP_SERVER_VARS [deprecated] โ€” Server and execution environment information ๏ฌ <?php echo $_SERVER['SERVER_NAME']; ?> By ProgrammerBlog.net http://programmerblog.net/
  • 27. Super Globals ๏ฌ $_ENV -- $HTTP_ENV_VARS [deprecated] โ€” Environment variables ๏ฌ <?php echo 'My username is ' .$_ENV["USER"] . '!'; ?> ๏ฌ $ip = $_SERVER['REMOTE_ADDR']; By ProgrammerBlog.net http://programmerblog.net/
  • 28. Super Globals ๏ฌ Thank you for viewing this slide. Hope this is helpful for you. ๏ฌ please visit our blog http://programmerblog.net Follow us on twitter https://twitter.com/progblogdotnet By ProgrammerBlog.net http://programmerblog.net/