1 / 11

PHP: User-Defined and Built-in Functions

PHP: User-Defined and Built-in Functions. Speaker: Chin-Chang Chang Date:2007.3.21. User-Defined Functions. function function_name (parameters) { entity; } function_name();. demo. hello(); function hello() { echo "Hello, world!"; }

deidra
Download Presentation

PHP: User-Defined and Built-in Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP: User-Defined and Built-in Functions Speaker: Chin-Chang Chang Date:2007.3.21

  2. User-Defined Functions • function function_name (parameters){ entity;} • function_name();

  3. demo • hello(); • function hello(){ echo "Hello, world!";} • http://stu.csie.ncnu.edu.tw/~beautidays.99/demo6.phps

  4. $GLOBALS (1/2) • $temp = 6;clear();echo $temp; • function clear(){ $temp = 0;} • http://stu.csie.ncnu.edu.tw/~beautidays.99/demo7.phps

  5. $GLOBALS (2/2) • $temp = 6;clear();echo $temp; • function clear(){ $GLOBALS[ 'temp' ] = 0;} • http://stu.csie.ncnu.edu.tw/~beautidays.99/demo8.phps

  6. demo • hi(Joe, 18); • hi(May, 23); • function hi($x, $y){echo $x . " is " . $y . " years old.<br>";} • http://stu.csie.ncnu.edu.tw/~beautidays.99/demo9.phps

  7. rand(); • rand($min, $max); • $i = rand();echo $i . "<br>";$j = rand(1,1000);echo $j; • http://stu.csie.ncnu.edu.tw/~beautidays.99/demo10.phps

  8. getdate(); • getdate(); • Return an array • $today=getdate();echo $today[year]; echo $today[mon];echo $today[mday]; • http://stu.csie.ncnu.edu.tw/~beautidays.99/date.phps

  9. strlen(); • strlen($string); • $s=“Good Afternoon”;$len=strlen($s);echo $s;echo “The length is ”.$len; • http://stu.csie.ncnu.edu.tw/~beautidays.99/strlength.phps

  10. Reference • http://www.php.net/docs.php • http://member.ettoday.com/book/

  11. HW3 • http://solomon.ipv6.club.tw/Course/Database.952/hw3.html • Two URLs: one for source code and one for execution.

More Related