Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP Arūnas Liuiza. PHP 101 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar.

Similar presentations


Presentation on theme: "PHP Arūnas Liuiza. PHP 101 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar."— Presentation transcript:

1 PHP Arūnas Liuiza

2 PHP 101

3 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar to C, Perl, Java PHP code snippets can be inserted to a HTML document

4 PHP Syntax

5 Inserting to HTML Long tags... Short tags ir Not recommended due to compatability reasons

6 Output Main function to output data: echo echo “Hello”; echo 12345;

7 Į TERPIMAS Į HTML. P AVYZDYS

8 Instruction separation Semicolon (;) is used to separate instructions from one another

9 Comments PHP has three types of comments Single line (till the end of line or ?>) : // comment # comment Multi-line /* comment carries to another line and another… */

10 Variables Symbolic name, that can have a value assigned to it Starts with dollar ($) sign $first First symbol has to be a letter or an underscore (_) $start $_with_underscore Can also contain numbers $p123_44dlsdm_ $_1234ps Variable names are Case Sensitive $Pirmas != $pirmas $DuKartai != $dukartai

11 Variables. Examples $foo = 15; echo ‘foo is ‘.$foo; $foo = “Peter”; echo ‘foo is ‘.$foo; $foo = “Peter”; $foo = “John”; echo ‘foo is ‘.$foo; foo is 15 foo is Peter foo is John CodeResult

12 Main PHP data types Boolean Logical true/false Integer 1, 2, 3, 4… Float 3.1415, 0.21513 String ‘Text’ Array Object Resource NULL No value

13 B OOLEAN Logical true or false value $a = true; $a = FaLsE; Possible FALSE values: FALSE 0 0.0 ‘’ ir ‘0’ Empty array Object without members NULL Anything else - TRUE

14 Type casting PHP does not require strict definition of variable data type – type is converted according to context

15 Operators PHP operators are divided to: Arithmetical Value assigning Comparison Logical

16 Arithmetical + Sum$a = 2 + 2 - Subtract$a = 4 – 2 * Multiply$a = 2 * 2 / Divide$a = 4 / 2 % Division module$a = 5 % 2 (=1) ++ Add 1++$a -- Subtract 1--$a. Connect two strings $a = “raga”. “nosis”

17 Value assigning = $x = $y += $x += $y$x = $x + $y -= $x -= $y$x = $x - $y *= $x *= $y$x = $x * $y /= $x /= $y$x = $x / $y.= $x.= $y$x = $x. $y %= $x %= $y$x = $x % $y

18 Comparison == Equal5==8 false != Not equal5!=8 true <> Not equal5<>8 true > More5>8 false < Less5<8 true >= More or equal5>=8 false <= Less or equal5<=5 true

19 Logical && AND || OR ! NOT

20 Exercise

21 Task no 1 1. Multiply N by 3 2. Add 15 to the result 3. Find module of division by 4 of the result 4. Add 2 to the result 5. Raise the result to the second power (Res 2 ) 6. Subtract 1.5 from the result 7. Divide result by 3 Write a program that executes the operations one by one, outputing the result after each operation


Download ppt "PHP Arūnas Liuiza. PHP 101 What is PHP? Widely popular dynamic interpreted opensource programming language, aimed for web development Syntax is simmilar."

Similar presentations


Ads by Google