SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
PHP Function

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
PHP Function
F function
function( F F ก F F )
{
…….. ;
…….. ;
return F F ก F ก ;
}

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
PHP Function
<?php
echo hello();
function hello()
{
return "hello";
}
?>

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
PHP Function
<?php
echo showNum(1);
function showNum($n)
{
if($n=="1")
{return 1;}
else if($n=="2")
{return 2;}
}
?>
projectsoft.biz
ก
Web Application F
PHP MySQL Ajax(jquery)
PHP Function
showStart(3);
function showStart($n){
$count1=1;
while($count1<=$n){$count2=1;
while($count2<=$count1)
{echo "*";$count2++;}
echo "<br />";
$count1++;}
}
projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
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
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
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
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
PHP String Replace
<?php
$str="anbncn";
echo str_replace("n","<br />",$str);
?>

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
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

ก
PHP String Length
<?php
$str="12345";
if(strlen($str)>6){echo "greater than 6 ";}
else{echo “less than 6”;}
?>

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
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
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
F ก

ก

file

<?php
$file_name="my_picture.jpg";
$type = substr($file_name, strpos($file_name,"."));
echo $type;
?>
F
ก
.jpg

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
ก

string

ก

string ก
ก
function strtolower()
<?php
$str1="HeLLoWoRLd";
$str2=strtolower($str1);
echo $str2;
?>

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F

ก

F ˈ
F ˈ

F ก
F ก F F
ก

string

ก

string ก
ก
function strtoupper()
<?php
$str1=“heLLoWoRld";
$str2= strtoupper($str1);
echo $str2;
?>

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F

ก

F ˈ
F ˈ

F

F F
F F F
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
ʾ
•
•
•
•
•
•
•
•

F function date()

function date()
F ก
F
ˈ
d
m
Y
ʾ ..
ก
y
ʾ ..
ก
H
ˈ
i
s
projectsoft.biz
ก
PHP MySQL Ajax(jquery)

F parameter
ʾ

Web Application F

ˈ sting

F
ก

F

<?php
$strDate1="2012-01-01";//
F
$strDate2="2012-02-1";//
echo DateDiff($strDate1,$strDate2);
// ก function DateDiff
F

F

F

// F function DateDiff
F
F $strDate1
$strDate2
function DateDiff($strDate1,$strDate2)
{
//
ˈ
F
// F
F 86400 ( 1
86400
)
F
return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 );
}
?> projectsoft.biz
PHP MySQL Ajax(jquery)

ก

Web Application F
ก

/F

<?php
//ก
echo date('Y-m-d', strtotime(' +1 day'));//

n

php
F

echo date('Y-m-d', strtotime('+60 day', strtotime("2012-5-2")));
//
ก
2 2554 60
//ก
กF
F
echo date('Y-m-d', strtotime(' -1 day'));//

echo date('Y-m-d', strtotime('-60 day', strtotime( "2012-1-31" )));
//
F
ก
1 2554 60
?>
projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
PHP Include

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F
PHP include
include(“
F.php”);
include(“
.php”);
F
ก
F
include
F F
F include1_1.php
<?php echo "Hello ";?>
<?php
include("include1_1.php");
echo " World";
?>
F F Hello World
projectsoft.biz
ก
PHP MySQL Ajax(jquery)

Web Application F

F
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
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
PHP + Include
<?php
include("function/showDate.php");
$date=showDate("2010-10-01");
echo $date;
?>
F

include

projectsoft.biz
ก
PHP MySQL Ajax(jquery)

function showDate F

Web Application F

Más contenido relacionado

La actualidad más candente

PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
Kanchilug
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
Yusuke Wada
 

La actualidad más candente (19)

Get into the FLOW with Extbase
Get into the FLOW with ExtbaseGet into the FLOW with Extbase
Get into the FLOW with Extbase
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Neo Technology
Neo TechnologyNeo Technology
Neo Technology
 
PerlでWeb API入門
PerlでWeb API入門PerlでWeb API入門
PerlでWeb API入門
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Perl5i
Perl5iPerl5i
Perl5i
 
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
 
ZCPE - PHP Conference 2015
ZCPE   - PHP Conference 2015ZCPE   - PHP Conference 2015
ZCPE - PHP Conference 2015
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Php with my sql
Php with my sqlPhp with my sql
Php with my sql
 
Introducation to php for beginners
Introducation to php for beginners Introducation to php for beginners
Introducation to php for beginners
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
PHP「参照渡しできるよ」(君の考えている参照渡しと同じとは言ってない)
 
DEV Čtvrtkon #76 - Fluent Interface
DEV Čtvrtkon #76 - Fluent InterfaceDEV Čtvrtkon #76 - Fluent Interface
DEV Čtvrtkon #76 - Fluent Interface
 

Similar a Session3

Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
wpnepal
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
smueller_sandsmedia
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
rajivmordani
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
Lin Yo-An
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
yangdj
 

Similar a Session3 (20)

symfony & jQuery (phpDay)
symfony & jQuery (phpDay)symfony & jQuery (phpDay)
symfony & jQuery (phpDay)
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
 
J query training
J query trainingJ query training
J query training
 
Make WordPress realtime.
Make WordPress realtime.Make WordPress realtime.
Make WordPress realtime.
 
Hooks WCSD12
Hooks WCSD12Hooks WCSD12
Hooks WCSD12
 
symfony & jQuery (PUG)
symfony & jQuery (PUG)symfony & jQuery (PUG)
symfony & jQuery (PUG)
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
OSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP hatersOSDC.TW - Gutscript for PHP haters
OSDC.TW - Gutscript for PHP haters
 
Phing101 or How to staff a build orchestra
Phing101 or How to staff a build orchestraPhing101 or How to staff a build orchestra
Phing101 or How to staff a build orchestra
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Php web backdoor obfuscation
Php web backdoor obfuscationPhp web backdoor obfuscation
Php web backdoor obfuscation
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Session3