Presentation is loading. Please wait.

Presentation is loading. Please wait.

IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.

Similar presentations


Presentation on theme: "IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander."— Presentation transcript:

1 IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander

2 What is PHP? PHP stands for Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many databases (MySQL, Oracle etc.) PHP is an open source software (OSS) PHP is free to download and use

3 What is a PHP File? PHP files may contain text, HTML tags and scripts PHP files are returned to the browser as plain HTML PHP files have a file extension of ".php", ".php3", or ".phtml"

4 NB You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.

5 Why PHP? PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is FREE to download from the official PHP resource: www.php.netwww.php.net PHP is easy to learn, and runs efficient on the server side

6 Basic PHP Syntax A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

7 Basic PHP Syntax A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Result on client: Hello World

8 Basic PHP Syntax A PHP scripting block always starts with. A PHP scripting block can be placed anywhere in the document. Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another. There are two basic statements to output text with PHP: echo and print.

9 elrond.tud.ttu.ee AK 213: –create this file as a xx.php and place it to W disk Home computer: –Save the file somewhere –ftp to ftp.tud.ttu.ee using your TTU username (something like t010668) and password –Upload the file into the public_html folder After that run the program: –Open a browser and input into the address: elrond.tud.ttu.ee/~t010668/xxx.php to see the result, where instead of 010688 use your (!) “matrikli number” / student code.

10 Variables in PHP All variables in PHP start with a $ sign symbol. Variables may contain strings, numbers, or arrays. <?php $txt="Hello World"; echo $txt; ?>

11 Output etc. To concatenate two or more variables together, use the dot (.) operator <?php $txt1="Hello World"; $txt2=1234; echo $txt1. " ". $txt2 ; ?>

12 Output etc. echo " Hello and welcome to my website. "

13 Output etc. <?php $txt1="world"; echo "Hello $txt1, hello php!" ; ?>

14 Environent variables Example 1 <?php // Environent variables store information about // the user's and server's environment $info=$_SERVER["HTTP_USER_AGENT"]; print("You are using $info "); print("Your address is: ". $_SERVER["REMOTE_ADDR"]); ?>

15 Environent variables

16 Environent variables Example 1 <?php $info=$_SERVER["HTTP_USER_AGENT"]; print("You are using $info "); print("Your address is: ". $_SERVER["REMOTE_ADDR"]); ?> General info:


Download ppt "IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander."

Similar presentations


Ads by Google