PHP (Hypertext Preprocessor) 1. PHP References From W3 Schools: PHP.
WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)
description
Transcript of WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)
![Page 1: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/1.jpg)
WELCOME TO THE WORLD OF PHP the ultimate (Hypertext WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)Preprocessor)
OverviewDefinitionHistoryUsesAdvantages/DisadvantagesAdvantages of PHP over ASPDifferences between PHP and Cold-fusionDifference between JSP and PHPBasic SyntaxComplex SyntaxSimilarities between ASP and PHP
![Page 2: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/2.jpg)
DefinitionDefinition
Programming Language Server-side scripting language Html Embedded Scripting Language
primary purpose of which to generate HTML
It focuses on the logic of how a page responds to user input, not how the page looks
![Page 3: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/3.jpg)
HistoryHistory
PHP is a language for creating interactive web sites over 3.3 million web sites around the world. Originally name: "Personal Home Page Tools" when it was created in
1994 by Rasmus Lerdorf to keep track of who was looking at his online resume
![Page 4: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/4.jpg)
Uses of PHPUses of PHP
Helps in reading and writing files Can do basic file and directory maintenance Take content, use in generation of files in various formats i.e. HTML
and PDF Manages graphic content Read, write info in database.
![Page 5: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/5.jpg)
Advantages of PHP and Advantages of PHP and DisadvantagesDisadvantages
Cost –free Cross-platform compatibility (Windows, Macintosh, or a version of
Unix, ): Compiled and built on 25 platforms
Error handling is not as sophisticated as ASP
![Page 6: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/6.jpg)
Advantages of PHP over ASPAdvantages of PHP over ASP
PHP runs faster than ASP PHP is Free . PHP is more efficient with memory PHP can be run on any system with no performance issues PHP is tightly integrated with MySQL ASP commonly uses Microsoft
Access which is much slower than MySQL More object oriented than ASP Database connections in PHP > 200% (higher)
![Page 7: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/7.jpg)
Differences between PHP and Cold-Differences between PHP and Cold-FusionFusion
Cold-Fusion: Web application development tool that allows developers to build dynamic data-driven applications for use
on the Internet and intranets
Cold Fusion PHP (Platform) Relatively limited platform selection. If compiled, runs
ieWindows, Solaris, Linux or HP/UX. (Language) Really fast and easy for display pages and database interaction Not as easy for the easy stuff, but
much easier for the hard stuff. (Database Support):Abstracts database connections, making them simple to use, Has extremely strong native DB
support
(File System Support):Adequate file support, but is quirky and not feature-rich Comprehensive file system
support (Error-handling):good try/catch functionality, making formal error handling possible has no formal error handling
![Page 8: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/8.jpg)
Basic/General SyntaxBasic/General Syntax
<?php ... ?>
<html><head><title>My first PHP page</title></head><body>This is normal HTML code<?php
// PHP code goes here?>Back into normal HTML</body></html>
![Page 9: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/9.jpg)
Variables in PHPVariables in PHP loosely “typed language” i.e given variable can be an integer, floating-point number, string,
object, or an array
Integer: mathematical data type and represents any whole number and usually can be any value from a negative value to a positive value.
floating-point number represents any value that contains a decimal point.
EXAMPLE OF AN INTEGER VARIABLE
<?php
// All of the following are numerically equivalent
$myint = 83;// Normal decimal notation
$myint = O123; // Octal notation for the # 83
$myint = 0x53; // Hexadecimal notation for # 83
?>
EXAMPLE OF AN INTEGER VARIABLE
<?php
// Both of the following are equivalent to 1.234
$myfloat = 1.234; // Standard decimal notation
$myfloat = .001234e3; // Scientific notation ?>
![Page 10: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/10.jpg)
Condition-code in PHPCondition-code in PHP
<html><?$var = date("H");if ($var <= 11) { echo "good morning";}else { if ($var > 11 and $var < 18) { echo "good afternoon"; } else { echo "good evening"; }}?></html>
![Page 11: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/11.jpg)
Functions in PHP codeFunctions in PHP code
SAMPLE CODE<? function show_form($value="") { ?>
<form action="submit.php3" method="post">
<input type=text name=value
value="<?echo $value?>">
<input type=submit>
</form>
<? }
![Page 12: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/12.jpg)
PHP EMAILPHP EMAIL
Built-in function called mail(), that helps sends email.
mail($receiver, $subject,
$message, "From: $sender");
NOTE: The mail() function
-return a variable
-true or false, with regard to whether the mail was sent
- echo information to your user, as to the email status.
$sent = mail($receiver, $subject, $message, "From: $sender");
if ($sent) {
echo "your message was sent";
}else {
echo "your message was not sent";
}
![Page 13: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/13.jpg)
ASP EMAIL CODE(An idea ASP EMAIL CODE(An idea with respect to ASP)with respect to ASP)
<% Dim MyBody Dim MyCDONTSMail%>
<% Set MyCDONTSMail = CreateObject("CDONTS.NewMail") MyCDONTSMail.From= "[email protected]" MyCDONTSMail.To= "[email protected]" MyCDONTSMail.Subject="This is a Test" MyBody = "Thank you for ordering that stuff" & vbCrLf MyBody = MyBody & "We appretiate your business" & vbCrLf MyBody = MyBody & "Your stuff will arrive within 7 business days" MyCDONTSMail.Body= MyBody MyCDONTSMail.Send set MyCDONTSMail=nothing%>
![Page 14: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/14.jpg)
Similaritites betweeen ASP and Similaritites betweeen ASP and PHPPHP
Similarities between PHP and ASPPositive Aspect Easy to develop. Easy database connection/configuration.
The presentation is separate from processing.
Negative Aspects They are scripting languages that has a narrow scope.
They are scalability.
![Page 15: WELCOME TO THE WORLD OF PHP the ultimate (Hypertext Preprocessor)](https://reader036.fdocuments.in/reader036/viewer/2022082506/56813f63550346895daa3455/html5/thumbnails/15.jpg)
Differences between JSP and PHPDifferences between JSP and PHP
JSP PHP
JSP uses Java as its scripting language defines its own scripting language, which looks and feels a lot like Perl. Uses VBScript
JSP is much more powerful, since it has access to all the Java libraries
access to PHP libraries
Object-Oriented, so leads to cleaner code that's easier to debug, maintain, and improve.
Also allows objects, but the object model is more primitive, and most scripted pages ignore PHP objects and just use normal variables.