Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating PHP Pages Chapter 5 PHP Structure and Syntax.

Similar presentations


Presentation on theme: "Creating PHP Pages Chapter 5 PHP Structure and Syntax."— Presentation transcript:

1 Creating PHP Pages Chapter 5 PHP Structure and Syntax

2 Basic PHP Scripts Embedded language refers to code that is embedded within a Web page (HTML/XHTML document) PHP code is typed directly into a Web page as a separate section Server recognizes embedded script and executes A Web page containing PHP code must be saved with an extension of.php to be processed by the scripting engine PHP code is never sent to a client’s Web browser; only the output of the processing is sent to the browser

3 Basic PHP Scripts The Web page generated from the PHP code, and XHTML elements found within the PHP file, is returned to the client A PHP file that does not contain any PHP code should be saved with an.html extension.php is the default extension that most Web servers use to process PHP scripts

4 Creating PHP Code Blocks Code declaration blocks are separate sections on a Web page that are interpreted by the scripting engine There are four types of code declaration blocks: Standard PHP script delimiters The element Short PHP script delimiters ASP-style script delimiters

5 Standard PHP Script Delimiters All scripts start with Program lines end in ";" or you get an error Code block: { //code here } (brace brackets) White space is generally ignored (not in strings) Comments are created using: // single line quote /* Multiple line block quote */

6 The Element The element identifies a script section in a Web page document Assign a value of "php" to the language attribute of the element to identify the code block as PHP

7 Short PHP Script Delimiters The syntax for the short PHP script delimiters is Short delimiters can be disabled in a Web server’s php.ini configuration file PHP scripts will not work if your Web site ISP does not support short PHP script delimiters Short delimiters can be used in XHTML documents, but not in XML documents

8 ASP-Style Script Delimiters The syntax for the ASP-style script delimiters is ASP-style script delimiters can be used in XHTML documents, but not in XML documents ASP-style script delimiters can be enabled or disabled in the php.ini configuration file To enable or disable ASP-style script delimiters, assign a value of “On” or “Off ” to the asp_tags directive in the php.ini configuration file

9 Parsing How the browser can read a text file and process it, that's a basic parsing method. Browsers parse web pages as they load Web servers with server side technologies like PHP parse web pages as they are being passed out to the browser You can embed sections of PHP inside html : Or you can call html from PHP : <?php $test = "Hello World!"; echo $test; <?php echo " Howdy … ?>

10 References References : 1.Anonymous.(n.d.). Apache HTTP Server Documentation Version 2.2. Retrieved from http://httpd.apache.org/docs/2.2/. http://httpd.apache.org/docs/2.2/ 2.Achour, M., Betz, F. (n.d.), PHP Manual. Retrieved from http://www.php.net/download-docs.php. http://www.php.net/download-docs.php 3.Anonymous. (n.d.). MySQL Reference Manual. Retrieved from http://downloads.mysql.com/docs/.http://downloads.mysql.com/docs/ 4.Naramore, E., Gerner, J., Le Scouarnec, Y., Stolz, J., Glass, M. K. (2005). Beginning PHP5, Apache, and MySQL® Web Development. Indianapolis, IN: Wiley Publishing, Inc.


Download ppt "Creating PHP Pages Chapter 5 PHP Structure and Syntax."

Similar presentations


Ads by Google