6. PHP Sub String Function
substr(string,start position,length );
F
<?php
$str="abc";
echo substr($str,1,1);
?>
F F b
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
7. PHP Sub String Function
<?php
$str="abc";
echo substr($str,1);
?>
F
F
F
bc
F
ก F F F
F
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
ˈ F
F
string
F
F
Web Application F
string
F ก
F ก
string
F
F
8. PHP Sub String Date
<?php
echo showDate("2010-10-18");
function showDate($date)
{
$day=substr($date,8,2);
$month=substr($date,5,2);
$year=substr($date,0,4);
return $day."/".$month."/".$year;
}
?>
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
9. PHP String Replace
<?php
$str="hello WORLD";
echo str_replace("hello","HELLO",$str);
?>
F F HELLO WORLD
ก
F
F F string
ก
F ก F ก
F
string
F
string F
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
string
11. PHP String Length
Function strlen() F
<?php
echo strlen("php");
?>
F F ˈ
php
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
ก
ก
F 3
string F
ก
13. PHP String Position
strpos($string, "find string")
Function strpos F
F
F F
string
$string
string
ก
find string
ก
F ก
<?php
$str="@bc";
echo strpos($str,"@");
?> ก
F
ก
0
ก
F 0
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
F
ก
F ก
F
F
F
F
Fก
F
F
F
14. PHP String Position
ก
F
F ก F
function strpos return false
<?php
$mystring = 'bc';
$findme = 'a';
$pos = strpos($mystring, $findme);
if ($pos === false) {
echo "The string ”.$findme.“ was not found in the string”;
}
?>
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F
18. F function date()
ʾ
ก F ก
ˆ
function date() F
• date("d/m/Y")
• ก F ก
F
ˆ
• date("H:i:s")
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
/ ʾ
/
•
ˆ
Web Application F
ˈ
:
F
:
F
24. PHP include
F
F include1_1.php F folder include
F
ก
<?php
include("include/include1_1.php");
echo " World";
?>
F
F
F
F
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
ˈ Hello World
F ก F
Web Application F
F
F
F
F ก include
25. PHP include + Function
F showDate.php
F function F
<?php
function showDate($date)
{
$day=substr($date,8,2);
$month=substr($date,5,2);
$year=substr($date,0,4);
return $day."/".$month."/".$year;
}
?>
projectsoft.biz
ก
PHP MySQL Ajax(jquery)
Web Application F