.


:




:

































 

 

 

 


PHP




: PHP - , HTML.

:

PHP ( "PHP: Hypertext Preprocessor") , HTML-.

, , , :

<html> <head> <title></title> </head> <body> <?php echo ", PHP-!";?> </body></html>

HTML- .

, html-, . , - , , , . :

echo ", PHP-!";

"" , :

<?...?>

PHP (, JavaScript), , , .. , .

, , .phtml .php, , , PHP , , .html.

:

.

1. "" (Notepad) testphp1.phtml :

<html><head><title> </title><?phpecho ", !";?></head><body></body></html>

2. :

<html><head><title> PHP</title></head><body><?php$i = 6; // $d = 4.89; // $str = "PHP !"; // echo ($i + $d);echo "<br>, ! ".$str;?></body></html>

3. , PHP dollar ($), , PHP . $i $d "<br>, !" $str.

4. , , , . , . :

if () { N1; } else { N2; }

:

<html><head><title> </title></head><body><?php$i = 6; // $v = 7;$d = 4.89; // $str = " !"; // echo ($i + $d);echo "<br>, !".$str; if($i == $v){ echo $i + $v;}else{ echo $i.$v;}?></body></html>

5. , . 67, . $i $v, echo $i.$v; : "6" "7". () !=, (, or, and, >, <= ..).

6. . , , . , $a++; $a .
$a = $b = 4;. testphp1.phtml :

<html><head><title> </title></head><body><?php$b = $a = 5;echo "<br> a=$a, b=$b";$c = $a++;echo "<br> a=$a, c=$c";$e = $d = ++$b;echo "<br> e=$e, d=$d, b=$b";$g = 10;$h = $g += 10;echo "<br> g=$g, h=$h";?></body></html>

7. , , $a = 5 5, b 5. $c = $a++; , $a 1. $d = ++$b; 1 $b, .

, (GET POST -- ).

1. "" (Notepad) testphp2.phtml :

<html><head><title> </title></head><body><?phpecho $message.", ".$name;?></body></html>

2. , message name , ?, (&). , Enter .

3. testphp2_form.html. :

<form name="myform" method="get" action="testphp2.phtml"><br>:<br><input type="text" name="message"><br>:<br><input type="text" name="name"><br><input type="submit" value=" "></form>

4. .

5. , , .

6. GET POST, .

7. <input type="text" name="name"> , , :

8. , , , " " .

9. , , (radiobutton):



10. , ( ).

.

1. 3 : testphp3_inc1.html, testphp3_inc2.html testphp3_inc3.html. .

2. testphp3.phtml, :

<html><head><title> </title></head><body bgcolor=silver><?php$file = "";if ($link == 1) { $file = "testphp3_inc1.html"; }if ($link == 2) { $file = "testphp3_inc2.html"; }if ($link == 3) { $file = "testphp3_inc3.html"; }if ($file == "") {?><h3>, c:</h3><a href="testphp3.phtml?link=1"> N1</a><br><a href="testphp3.phtml?link=2"> N2</a><br><a href="testphp3.phtml?link=3"> N3</a> <? } else { include($file);}?></body></html>

3. , testphp3.phtml.

4. , .

5. , ; , , .

6. $titles, . <title>...</title> .

7. , . ( ) , ( ) . , / . .

8. testphp3_inc1.html, testphp3_inc2.html testphp3_inc3.html includes .

.

1. testphp4_form.html, , <textarea name=message cols=10 rows=4></textarea>, <input type=text name=person> .

2. , testphp4.phtml.

3. testphp4.phtml, :

<html><head><title> </title></head><body bgcolor=silver><?php$filename = "messages.txt"; $fp = fopen($filename,"a"); if($fp){ fputs($fp, $message." ".$person); fclose($fp); } include($filename);?></body></html>

4. messages.txt .

5. testphp4_form.html, .

6. : $message $person testphp4.phtml, messages.txt ( fopen, ), , , ( fputs, ).

7. , , , .

8. , testphp4.phtml, , testphp4_form.html.

9. guestbook.jpg.

 

:

1. , ?

2. html?

3. .

4. PHP?

5. PHP.

 

4





:


: 2017-01-28; !; : 933 |


:

:

,
==> ...

1723 - | 1490 -


© 2015-2024 lektsii.org - -

: 0.021 .