SlideShare a Scribd company logo
1 of 61
Download to read offline
1
PHP
 echo, print

 echo (variable
functions)

2
PHP
 echo, print
Demo
<? #ecpr.php
function TestSet($a){
print("$a is $a");
}
$iTestSet = "TestSet";
$iTestSet(5);
?>
3
PHP
 settype()
 data type

 settype($varname, “datatype”);
Demo
<? #settype.php
settype($i, "integer");
?>
4
PHP
 gettype()
 data type

 gettype($varname);
Demo
<? #settype.php
settype($i, "integer");
print(gettype($i));
?>
5
PHP
 isset()
 ( = 1, =
blank)

 isset($varname);
Demo
<? #isset.php
settype($i, "integer");
print(gettype($i));
print("<br>".isset($a));
print("<br>".isset($i));
?>
6
Introduction to HTML
 HTML
<html>
<head>
<!-- comment for HTML -->
</head>
<body>
</body>
</html>
7
Introduction to HTML
 HTML
<html>
<head>
<!-- comment for HTML -->
</head>
<!-- comment -->
<body>
<h1>php with html</h1>
<?php
//---
print "PHP with HTML";
?>
<form>
<?php
//---
?>
</form>
</body>
</html>
8
Introduction to HTML
 HTML
<!--comment for HTML-->
<html>
<head>
<title>MyHTML</title>
</head>
<body>
</body>
</html>
9
Introduction to HTML
 HTML
background
background
bgcolor background
text foreground
events onLoad, onUpload
10
Introduction to HTML
 form
Action URL submit
Method
Get URL
URL
browser
POST URL
Name
control
<input>
<textarea>
11
Introduction to HTML
 input type
 text
 password
 button
 reset
 submit
 radio
 checkbox
 hidden
12
Introduction to HTML
 input
type
user
name
Value
13
Introduction to HTML
 input - text
name
value
size
maxlength
events onChange, onKeyUp
14
Introduction to HTML
 input - password
name
value
(encrypted)
size
maxlength
events onChange, onKeyUp
15
Introduction to HTML
 input – button, reset, submit
name
value
events onChange, onKeyUp
16
Introduction to HTML
 input – radio, checkbox
name
value name
checked
events onClick
17
Introduction to HTML
 input – hidden
name hidden
value name
submit
18
Introduction to HTML
 table
border
width
height
19
Introduction to HTML
 tr, td, th
align
valign
bgcolor
width
height
20
Introduction to HTML
Demo – table.htm
<!-- table.htm -->
<html>
<head></head>
<body>
<table border="1"> <!-- tag table opened here -->
<tr> <!-- tag tr for row opened here -->
<th>No.</th> <!-- tag th for table header -->
<th>col1</th>
<th>col2</th>
</tr> <!-- tag th for table header -->
<tr>
<td>row1</td> <!-- tag td for column detail -->
<td>table detail row 1 column 1</td>
<td>table detail row 1 column 2</td>
</tr>
<tr>
<td>row2</td>
<td>table detail row 2 column 1</td>
<td>table detail row 2 column 2</td>
</tr>
</table> <!-- tag table closed here -->
</body>
</html>
21
Introduction to HTML
Demo – frminput.htm
<!-- frminput.htm -->
<html><!-- frminput.htm-->
<head><title>Input form</title></head>
<body>
<form name="frmInput" method="post" action="getInfo.php">
Student Name :<input type=text name=txtName><br>
Student ID :<input type=text name=txtID><br>
Sex : <select name=selSex>
<option value=M> </option>
<option value=W> </option>
</select>
Score :<input type=text name=txtScore><br>
<input type=submit value=Submit><br>
</form>
</body>
</html>
22
Introduction to HTML
Demo – getinfo.php
<? #getinfo.php
echo "<center><h3>";
print " <br>";
print " $txtName<br>";
print " $txtID<br>";
switch($selSex){
case "M" : $selSex=" "; break;
default : $selSex=" "; break;
}
print " $selSex<br>";
if($txtScore < 50){
$getGrade = "D";
}elseif($txtScore < 65){
$getGrade = "C";
}elseif($txtScore < 80){
$getGrade = "B";
}else{
$getGrade = "A";}
print " $getGrade<br>";
echo "</h3></center>";
?>
23
Introduction to HTML
Demo – frmInput02.htm
<html>
<head></head>
<body>
<form name="frmInput" method="post" action="getInfo02.php">
<table>
<tr>
<td align="right">Student Name:</td>
<td><input type=text name=txtName></td>
</tr>
<tr>
<td align="right">Student ID:</td>
<td><input type=text name=txtID></td>
</tr>
24
Introduction to HTML
Demo – frmInput02.htm (
<tr>
<td align="right">Sex:</td>
<td>
<select name=selSex>
<option value=M> </option>
<option value=F> </option>
</select>
</td>
</tr>
<tr>
<td align="right">Score:</td>
<td><input type=text name=txtScore></td>
</tr>
<tr>
<td colspan="2" align="center"><input type=submit value=Submit></td>
</tr>
</table>
</form>
</body>
</html>
25
Introduction to HTML
Demo – getInfo2.php
<? #getinfo02.php
echo "<center><h3>";
print "
<br>";
print " $txtName<br>";
print " $txtID<br>";
switch($selSex){
case "M“ :$selSex=“ "; break;
default :$selSex=“ ";break;
}
26
Introduction to HTML
Demo – getInfo2.php (
print " $selSex<br>";
if($txtScore < 50)
$getGrade = "D";
elseif($txtScore < 65)
$getGrade = "C";
elseif($txtScore < 80)
$getGrade = "B";
else
$getGrade = "A";
print " $getGrade<br>";
echo "<h3></center>";
?>
27
PHP
substr()


 substr(string string, int start[, int length]);
 string
 start
0
 length
28
PHP
Demo – substr.php
<? //substr.php
$text = "integer is number";
print(substr($text, 0, 7));
?>
29
PHP
substr_replace()


 substr_replace(string string, string replacement,
int start[, int length]);
string
replacement
start
0
30
PHP
Demo – substrrp.php
<?php #substrrp.php
$text = "integer is number";
$newtext = substr($text, 0, 10);
print($newtext."<br>");
$newtext = substr_replace($newtext, " not float", 11);
print($newtext."<br>");
$newtext = substr_replace($text, " not float", 11);
print($newtext."<br>");
$newtext = substr_replace($text, " not float", 11,0);
print($newtext."<br>");
?>
31
PHP
 str_replace()


 mixed str_replace(mixed search, mixed replace,
mixed subject[, int &count]);
search
replace
subject
count
(pass by reference)
&
32
PHP
str_replace()
Demo – strrp.php
<?php #strrp.php
$oldstr = "integer is number";
$newstr = str_replace("integer", "float",
$oldstr);
print($newstr."<br>");
?>
33
PHP
 strpos()


 int strpos(string haystack, string needle [, int
offset]);
haystack
needle
offset
optional parameter
34
PHP
strpos()
Demo – strpos.php
<?php #strpos.php
$email = "chatchag@hotmail.com";
$name = substr($email, 0, strpos($email, "@"));
print("Name : ".$name."<br>");
$domain = substr($email, strpos($email, "@")+1, 11);
print("Domain : ".$domain."<br>");
?>
35
PHP
DEMO - frminputstrpos2.htm
<!-- frminputstrpos2.htm -->
<html><!-- frminputstrpos2.htm-->
<head><title>Input form</title></head>
<body></body>
<form name="frmInput" method="post" action="strpos2.php">
E-mail :<input type=text name=txtEMail><br>
Year :<input type=text name=txtID><br>
<input type=submit value=Submit><br>
</form>
</html>
36
PHP
strpos()
Demo – strpos2.php
<?php #strpos2.php
print "<h1>";
print “ 25".substr($txtID, 2, 2)."<br>";
print “ e-Mail : ";
print substr($txtEMail, 0, strpos($txtEMail, "@"));
print "<br>";
print "Domain : ".substr($txtEMail, strpos($txtEMail, "@")+1);
print "<br>";
print "</h1>";
?>
37
PHP
 strrpos()

strpos()

 int strrpos(string haystack, string needle [, int offset]);
haystack
needle
offset
optional parameter
38
PHP
strrpos()
Demo – strrpos.php
<?php #strrpos.php
$email = "chatchag@tot.co.th";
print strpos($email, "a")."<br>";
print strrpos($email, "a")."<br>";
?>
39
PHP
 strlen()
int strlen(string, string);
DEMO strlen()
<?php #strlen.php
$email = "chatchag@tot.co.th";
print("email length ".strlen($email)."<br>");
$name = substr($email, 0, strpos($email, "@"));
print("name length ".strlen($name)."<br>");
$domain = substr($email, strpos($email, "@")+1);
print("domain length ".strlen($domain)."<br>");
?>
40
PHP
 ltrim(), rtrim(), trim(), chop()

 trim()
 ltrim()
 rtrim()
 chop()

trim(string string)
41
PHP
 ltrim(), rtrim(), trim(), chop()
Demo
<?php #trim.php
$email = " chatchag@tot.co.th ";
print "all ".".".$email.".<br>";
print "trim ".".".trim($email).".<br>";
print "ltrim ".".".ltrim($email).".<br>";
print "rtrim ".".".rtrim($email).".<br>";
print "chop ".".".chop($email).".<br>";
?>
42
PHP
 list()


 list($var1[, $var2, [$var3, …]])
$vari i
43
PHP
 explode()


 array explode(string separator, string [, int limit])

 separator
 string
 limit
44
PHP
 explode()
Demo
<?php #explode.php
$email = " chatchag@tot.co.th ";
list($name, $domain) = explode("@", $email);
print $name."<br>";
print $domain."<br>";
?>
45
PHP
 explode()
Demo
<?php #explode2.php
$email = " system@chatchag@tot.co.th ";
list($sys, $name, $domain) = explode("@",$email, 3);
print $sys."<br>";
print $name."<br>";
print $domain."<br>";
?>
46
PHP
 implode()
 element
array


 string implode(string glue, array pieces)

 glue
 pieces array
47
PHP
 implode()
Demo
<?php #implode.php
$email = "chatchag@tot.co.th";
list($name[], $domain) = explode("@", $email);
print $name[0]."<br>";
print $domain."<br>";
$name[] = "yahoo.com";
$newemail = implode("@", $name);
print $newemail."<br>";
?>
48
PHP
 implode()
Demo
<?php #implode2.php
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode("@", $array);
echo $comma_separated;
?>
49
PHP
 strtolower(), strtoupper()

 strtolower()
 strtoupper()
Demo
<?php #strtou.php
$email = "chatchag@tot.co.th"."<br>";
print strtoupper($email);
$email = "CHATCHAG@TOT.CO.HT";
print strtolower($email);
?>
50
PHP
 ucfirst(), ucwords()

 ucfirst()
 ucwords()
Demo
<?php #ucwords.php
$email = "chatchag@ tot.co.th hotmail.com"."<br>";
print ucwords($email);
$email = "chatchag@ tot.co.th hotmail.com";
print ucfirst($email);
?>
51
PHP
 strcmp()
 string 2

 int strcmp(string str1, string str2)
 str1, str2
Demo
<?php #strcmp php
$email1 chatchag@tot co th ;
$email2 chatchag@yahoo com ;
print strcmp $email1, $email1 <br> ;
print strcmp $email1, $email2 <br> ;
print strcmp $email2, $email1 <br> ;
?>
52
PHP
 printf(), sprintf()
void printf(string format [,mixed args])
string sprintf(string format [,mixed args])
type specifier
%
53
PHP
 printf(), sprintf()
(type specifier)
b argument
c argument Ascii
code
d argument
u argument
f argument
o argument
s argument string
x argument
54
PHP
Demo
<? //sprintf.php
$format = "chocolate 2 %s, is 129 %s. ";
$output = sprintf($format, "scoop(s)", "Baht");
print $output."<br>";
?>
<? //printf.php
$model = "AF-111";$unitprice = "25230.255";
$format = “ %s = %.2f ";
printf($format, $model, $unitprice)."<br>";
?>
55
PHP
 is_int(), is_integer()
 integer
Demo
<? //isint.php
$i = 1.30;
#settype($i, "integer");
if(is_int($i))
print $i." is an integer.<br>";
else
print $i." is not an integer.<br>";
?>
56
PHP
 is_float(), is_double()

Demo
<? //isfloat.php
$i = 1.30;
#settype($i, "integer");
if(is_float($i))
print $i." is an float.<br>";
else
print $i." is not an float.<br>";
?>
57
PHP
 decbin(), bindec()
decbin()
bindec()
Demo
<? //decbin.php
$d = 10;
print $d." is ".decbin($d).".<br>";
$b = 1001;
print $b." is ".bindec($b).".<br>";
?>
58
PHP
 decoct(), octdec()
decoct()
octdec()
Demo
<? //decoct.php
$d = 10;
print $d." is ".decoct($d).".<br>";
$o = 20;
print $o." is ".octdec($o).".<br>";
?>
59
PHP
 dechex(), hexdec()
dechex()
hexdec()
Demo
<? //dechex.php
$d = 10;
print $d." is ".dechex($d).".<br>";
$h = a;
print $h." is ".hexdec($h).".<br>";
?>
60
PHP
 floor(), ceil(), round()
floor()
ceil()
round()
float round(float val [, int precision])
val
0 default 0
61
PHP
 floor(), ceil(), round()
Demo
<?php #round.php
$num1 = 123.2563;
$num2 = 235.2566;
$avg = ($num1 + $num2)/2;
print $avg."<br>";
print round($avg,2)."<br>";
print round($avg,-1)."<br>";
print floor($avg)."<br>";
print ceil($avg)."<br>";
?>

More Related Content

What's hot

The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type Systemabrummett
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6garux
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and ProfitOlaf Alders
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perlgarux
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlordsheumann
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbiaDamien Seguy
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodJeremy Kendall
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
R57shell
R57shellR57shell
R57shellady36
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopJeroen Keppens
 
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)James Titcumb
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)James Titcumb
 

What's hot (20)

Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Wsomdp
WsomdpWsomdp
Wsomdp
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
I, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 OverlordsI, For One, Welcome Our New Perl6 Overlords
I, For One, Welcome Our New Perl6 Overlords
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbia
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
R57shell
R57shellR57shell
R57shell
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark Workshop
 
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)Dip Your Toes in the Sea of Security (PHP South Africa 2017)
Dip Your Toes in the Sea of Security (PHP South Africa 2017)
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)Climbing the Abstract Syntax Tree (PHP South Africa 2017)
Climbing the Abstract Syntax Tree (PHP South Africa 2017)
 

Viewers also liked

4 - statement
4  - statement4  - statement
4 - statementskiats
 
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 functiontumetr1
 
การใช้งาน phpMyadmin
การใช้งาน phpMyadminการใช้งาน phpMyadmin
การใช้งาน phpMyadminskiats
 
PHPBarcelona Conference - Optimización aplicaciones PHP - Client side
PHPBarcelona Conference - Optimización aplicaciones PHP - Client sidePHPBarcelona Conference - Optimización aplicaciones PHP - Client side
PHPBarcelona Conference - Optimización aplicaciones PHP - Client sidemaguilar
 
Servidor Web Apache, PHP, MySQL.
Servidor Web Apache, PHP, MySQL.Servidor Web Apache, PHP, MySQL.
Servidor Web Apache, PHP, MySQL.Ángel Acaymo M. G.
 

Viewers also liked (6)

4 - statement
4  - statement4  - statement
4 - statement
 
PHP Tutorial (array)
PHP Tutorial (array)PHP Tutorial (array)
PHP Tutorial (array)
 
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
 
การใช้งาน phpMyadmin
การใช้งาน phpMyadminการใช้งาน phpMyadmin
การใช้งาน phpMyadmin
 
PHPBarcelona Conference - Optimización aplicaciones PHP - Client side
PHPBarcelona Conference - Optimización aplicaciones PHP - Client sidePHPBarcelona Conference - Optimización aplicaciones PHP - Client side
PHPBarcelona Conference - Optimización aplicaciones PHP - Client side
 
Servidor Web Apache, PHP, MySQL.
Servidor Web Apache, PHP, MySQL.Servidor Web Apache, PHP, MySQL.
Servidor Web Apache, PHP, MySQL.
 

Similar to PHP Tutorial (funtion)

Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...Jitendra Kumar Gupta
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1Kanchilug
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Hitesh Patel
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code ReviewDamien Seguy
 
WTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio AkitaWTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio AkitaiMasters
 
PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. wahidullah mudaser
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)Dennis Knochenwefel
 

Similar to PHP Tutorial (funtion) (20)

PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...
 
Php (1)
Php (1)Php (1)
Php (1)
 
07 php
07 php07 php
07 php
 
Presentaion
PresentaionPresentaion
Presentaion
 
07-PHP.pptx
07-PHP.pptx07-PHP.pptx
07-PHP.pptx
 
07-PHP.pptx
07-PHP.pptx07-PHP.pptx
07-PHP.pptx
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Php functions
Php functionsPhp functions
Php functions
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Html , php, mysql intro
Html , php, mysql introHtml , php, mysql intro
Html , php, mysql intro
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code Review
 
WTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio AkitaWTF Oriented Programming, com Fabio Akita
WTF Oriented Programming, com Fabio Akita
 
PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array.
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Ip lab
Ip labIp lab
Ip lab
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
Php101
Php101Php101
Php101
 

Recently uploaded

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 

Recently uploaded (20)

Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 

PHP Tutorial (funtion)

  • 1. 1 PHP  echo, print   echo (variable functions) 
  • 2. 2 PHP  echo, print Demo <? #ecpr.php function TestSet($a){ print("$a is $a"); } $iTestSet = "TestSet"; $iTestSet(5); ?>
  • 3. 3 PHP  settype()  data type   settype($varname, “datatype”); Demo <? #settype.php settype($i, "integer"); ?>
  • 4. 4 PHP  gettype()  data type   gettype($varname); Demo <? #settype.php settype($i, "integer"); print(gettype($i)); ?>
  • 5. 5 PHP  isset()  ( = 1, = blank)   isset($varname); Demo <? #isset.php settype($i, "integer"); print(gettype($i)); print("<br>".isset($a)); print("<br>".isset($i)); ?>
  • 6. 6 Introduction to HTML  HTML <html> <head> <!-- comment for HTML --> </head> <body> </body> </html>
  • 7. 7 Introduction to HTML  HTML <html> <head> <!-- comment for HTML --> </head> <!-- comment --> <body> <h1>php with html</h1> <?php //--- print "PHP with HTML"; ?> <form> <?php //--- ?> </form> </body> </html>
  • 8. 8 Introduction to HTML  HTML <!--comment for HTML--> <html> <head> <title>MyHTML</title> </head> <body> </body> </html>
  • 9. 9 Introduction to HTML  HTML background background bgcolor background text foreground events onLoad, onUpload
  • 10. 10 Introduction to HTML  form Action URL submit Method Get URL URL browser POST URL Name control <input> <textarea>
  • 11. 11 Introduction to HTML  input type  text  password  button  reset  submit  radio  checkbox  hidden
  • 12. 12 Introduction to HTML  input type user name Value
  • 13. 13 Introduction to HTML  input - text name value size maxlength events onChange, onKeyUp
  • 14. 14 Introduction to HTML  input - password name value (encrypted) size maxlength events onChange, onKeyUp
  • 15. 15 Introduction to HTML  input – button, reset, submit name value events onChange, onKeyUp
  • 16. 16 Introduction to HTML  input – radio, checkbox name value name checked events onClick
  • 17. 17 Introduction to HTML  input – hidden name hidden value name submit
  • 18. 18 Introduction to HTML  table border width height
  • 19. 19 Introduction to HTML  tr, td, th align valign bgcolor width height
  • 20. 20 Introduction to HTML Demo – table.htm <!-- table.htm --> <html> <head></head> <body> <table border="1"> <!-- tag table opened here --> <tr> <!-- tag tr for row opened here --> <th>No.</th> <!-- tag th for table header --> <th>col1</th> <th>col2</th> </tr> <!-- tag th for table header --> <tr> <td>row1</td> <!-- tag td for column detail --> <td>table detail row 1 column 1</td> <td>table detail row 1 column 2</td> </tr> <tr> <td>row2</td> <td>table detail row 2 column 1</td> <td>table detail row 2 column 2</td> </tr> </table> <!-- tag table closed here --> </body> </html>
  • 21. 21 Introduction to HTML Demo – frminput.htm <!-- frminput.htm --> <html><!-- frminput.htm--> <head><title>Input form</title></head> <body> <form name="frmInput" method="post" action="getInfo.php"> Student Name :<input type=text name=txtName><br> Student ID :<input type=text name=txtID><br> Sex : <select name=selSex> <option value=M> </option> <option value=W> </option> </select> Score :<input type=text name=txtScore><br> <input type=submit value=Submit><br> </form> </body> </html>
  • 22. 22 Introduction to HTML Demo – getinfo.php <? #getinfo.php echo "<center><h3>"; print " <br>"; print " $txtName<br>"; print " $txtID<br>"; switch($selSex){ case "M" : $selSex=" "; break; default : $selSex=" "; break; } print " $selSex<br>"; if($txtScore < 50){ $getGrade = "D"; }elseif($txtScore < 65){ $getGrade = "C"; }elseif($txtScore < 80){ $getGrade = "B"; }else{ $getGrade = "A";} print " $getGrade<br>"; echo "</h3></center>"; ?>
  • 23. 23 Introduction to HTML Demo – frmInput02.htm <html> <head></head> <body> <form name="frmInput" method="post" action="getInfo02.php"> <table> <tr> <td align="right">Student Name:</td> <td><input type=text name=txtName></td> </tr> <tr> <td align="right">Student ID:</td> <td><input type=text name=txtID></td> </tr>
  • 24. 24 Introduction to HTML Demo – frmInput02.htm ( <tr> <td align="right">Sex:</td> <td> <select name=selSex> <option value=M> </option> <option value=F> </option> </select> </td> </tr> <tr> <td align="right">Score:</td> <td><input type=text name=txtScore></td> </tr> <tr> <td colspan="2" align="center"><input type=submit value=Submit></td> </tr> </table> </form> </body> </html>
  • 25. 25 Introduction to HTML Demo – getInfo2.php <? #getinfo02.php echo "<center><h3>"; print " <br>"; print " $txtName<br>"; print " $txtID<br>"; switch($selSex){ case "M“ :$selSex=“ "; break; default :$selSex=“ ";break; }
  • 26. 26 Introduction to HTML Demo – getInfo2.php ( print " $selSex<br>"; if($txtScore < 50) $getGrade = "D"; elseif($txtScore < 65) $getGrade = "C"; elseif($txtScore < 80) $getGrade = "B"; else $getGrade = "A"; print " $getGrade<br>"; echo "<h3></center>"; ?>
  • 27. 27 PHP substr()    substr(string string, int start[, int length]);  string  start 0  length
  • 28. 28 PHP Demo – substr.php <? //substr.php $text = "integer is number"; print(substr($text, 0, 7)); ?>
  • 29. 29 PHP substr_replace()    substr_replace(string string, string replacement, int start[, int length]); string replacement start 0
  • 30. 30 PHP Demo – substrrp.php <?php #substrrp.php $text = "integer is number"; $newtext = substr($text, 0, 10); print($newtext."<br>"); $newtext = substr_replace($newtext, " not float", 11); print($newtext."<br>"); $newtext = substr_replace($text, " not float", 11); print($newtext."<br>"); $newtext = substr_replace($text, " not float", 11,0); print($newtext."<br>"); ?>
  • 31. 31 PHP  str_replace()    mixed str_replace(mixed search, mixed replace, mixed subject[, int &count]); search replace subject count (pass by reference) &
  • 32. 32 PHP str_replace() Demo – strrp.php <?php #strrp.php $oldstr = "integer is number"; $newstr = str_replace("integer", "float", $oldstr); print($newstr."<br>"); ?>
  • 33. 33 PHP  strpos()    int strpos(string haystack, string needle [, int offset]); haystack needle offset optional parameter
  • 34. 34 PHP strpos() Demo – strpos.php <?php #strpos.php $email = "chatchag@hotmail.com"; $name = substr($email, 0, strpos($email, "@")); print("Name : ".$name."<br>"); $domain = substr($email, strpos($email, "@")+1, 11); print("Domain : ".$domain."<br>"); ?>
  • 35. 35 PHP DEMO - frminputstrpos2.htm <!-- frminputstrpos2.htm --> <html><!-- frminputstrpos2.htm--> <head><title>Input form</title></head> <body></body> <form name="frmInput" method="post" action="strpos2.php"> E-mail :<input type=text name=txtEMail><br> Year :<input type=text name=txtID><br> <input type=submit value=Submit><br> </form> </html>
  • 36. 36 PHP strpos() Demo – strpos2.php <?php #strpos2.php print "<h1>"; print “ 25".substr($txtID, 2, 2)."<br>"; print “ e-Mail : "; print substr($txtEMail, 0, strpos($txtEMail, "@")); print "<br>"; print "Domain : ".substr($txtEMail, strpos($txtEMail, "@")+1); print "<br>"; print "</h1>"; ?>
  • 37. 37 PHP  strrpos()  strpos()   int strrpos(string haystack, string needle [, int offset]); haystack needle offset optional parameter
  • 38. 38 PHP strrpos() Demo – strrpos.php <?php #strrpos.php $email = "chatchag@tot.co.th"; print strpos($email, "a")."<br>"; print strrpos($email, "a")."<br>"; ?>
  • 39. 39 PHP  strlen() int strlen(string, string); DEMO strlen() <?php #strlen.php $email = "chatchag@tot.co.th"; print("email length ".strlen($email)."<br>"); $name = substr($email, 0, strpos($email, "@")); print("name length ".strlen($name)."<br>"); $domain = substr($email, strpos($email, "@")+1); print("domain length ".strlen($domain)."<br>"); ?>
  • 40. 40 PHP  ltrim(), rtrim(), trim(), chop()   trim()  ltrim()  rtrim()  chop()  trim(string string)
  • 41. 41 PHP  ltrim(), rtrim(), trim(), chop() Demo <?php #trim.php $email = " chatchag@tot.co.th "; print "all ".".".$email.".<br>"; print "trim ".".".trim($email).".<br>"; print "ltrim ".".".ltrim($email).".<br>"; print "rtrim ".".".rtrim($email).".<br>"; print "chop ".".".chop($email).".<br>"; ?>
  • 42. 42 PHP  list()    list($var1[, $var2, [$var3, …]]) $vari i
  • 43. 43 PHP  explode()    array explode(string separator, string [, int limit])   separator  string  limit
  • 44. 44 PHP  explode() Demo <?php #explode.php $email = " chatchag@tot.co.th "; list($name, $domain) = explode("@", $email); print $name."<br>"; print $domain."<br>"; ?>
  • 45. 45 PHP  explode() Demo <?php #explode2.php $email = " system@chatchag@tot.co.th "; list($sys, $name, $domain) = explode("@",$email, 3); print $sys."<br>"; print $name."<br>"; print $domain."<br>"; ?>
  • 46. 46 PHP  implode()  element array    string implode(string glue, array pieces)   glue  pieces array
  • 47. 47 PHP  implode() Demo <?php #implode.php $email = "chatchag@tot.co.th"; list($name[], $domain) = explode("@", $email); print $name[0]."<br>"; print $domain."<br>"; $name[] = "yahoo.com"; $newemail = implode("@", $name); print $newemail."<br>"; ?>
  • 48. 48 PHP  implode() Demo <?php #implode2.php <?php $array = array('lastname', 'email', 'phone'); $comma_separated = implode("@", $array); echo $comma_separated; ?>
  • 49. 49 PHP  strtolower(), strtoupper()   strtolower()  strtoupper() Demo <?php #strtou.php $email = "chatchag@tot.co.th"."<br>"; print strtoupper($email); $email = "CHATCHAG@TOT.CO.HT"; print strtolower($email); ?>
  • 50. 50 PHP  ucfirst(), ucwords()   ucfirst()  ucwords() Demo <?php #ucwords.php $email = "chatchag@ tot.co.th hotmail.com"."<br>"; print ucwords($email); $email = "chatchag@ tot.co.th hotmail.com"; print ucfirst($email); ?>
  • 51. 51 PHP  strcmp()  string 2   int strcmp(string str1, string str2)  str1, str2 Demo <?php #strcmp php $email1 chatchag@tot co th ; $email2 chatchag@yahoo com ; print strcmp $email1, $email1 <br> ; print strcmp $email1, $email2 <br> ; print strcmp $email2, $email1 <br> ; ?>
  • 52. 52 PHP  printf(), sprintf() void printf(string format [,mixed args]) string sprintf(string format [,mixed args]) type specifier %
  • 53. 53 PHP  printf(), sprintf() (type specifier) b argument c argument Ascii code d argument u argument f argument o argument s argument string x argument
  • 54. 54 PHP Demo <? //sprintf.php $format = "chocolate 2 %s, is 129 %s. "; $output = sprintf($format, "scoop(s)", "Baht"); print $output."<br>"; ?> <? //printf.php $model = "AF-111";$unitprice = "25230.255"; $format = “ %s = %.2f "; printf($format, $model, $unitprice)."<br>"; ?>
  • 55. 55 PHP  is_int(), is_integer()  integer Demo <? //isint.php $i = 1.30; #settype($i, "integer"); if(is_int($i)) print $i." is an integer.<br>"; else print $i." is not an integer.<br>"; ?>
  • 56. 56 PHP  is_float(), is_double()  Demo <? //isfloat.php $i = 1.30; #settype($i, "integer"); if(is_float($i)) print $i." is an float.<br>"; else print $i." is not an float.<br>"; ?>
  • 57. 57 PHP  decbin(), bindec() decbin() bindec() Demo <? //decbin.php $d = 10; print $d." is ".decbin($d).".<br>"; $b = 1001; print $b." is ".bindec($b).".<br>"; ?>
  • 58. 58 PHP  decoct(), octdec() decoct() octdec() Demo <? //decoct.php $d = 10; print $d." is ".decoct($d).".<br>"; $o = 20; print $o." is ".octdec($o).".<br>"; ?>
  • 59. 59 PHP  dechex(), hexdec() dechex() hexdec() Demo <? //dechex.php $d = 10; print $d." is ".dechex($d).".<br>"; $h = a; print $h." is ".hexdec($h).".<br>"; ?>
  • 60. 60 PHP  floor(), ceil(), round() floor() ceil() round() float round(float val [, int precision]) val 0 default 0
  • 61. 61 PHP  floor(), ceil(), round() Demo <?php #round.php $num1 = 123.2563; $num2 = 235.2566; $avg = ($num1 + $num2)/2; print $avg."<br>"; print round($avg,2)."<br>"; print round($avg,-1)."<br>"; print floor($avg)."<br>"; print ceil($avg)."<br>"; ?>