Sunteți pe pagina 1din 10

CLUBUL DE INFO APLICAT AL C.N.

NICU GANE
BAZELE PHP
HELLO, WORLD

<html> <html>
<head> <head>
<title>Exemplu PHP</title> <title>Exemplu PHP</title>
</head> </head>
<body> <body>
<?php Hello, world!
echo Hello, world!; </body>
?> </html>
</body>
</html>
EXEMPLE
<div> <p style=text-align:center> <ul>
<?php <?php <?php
$a = 2; $a = 2; for($i=1;$i<=4;$i++){
$b = 3; $b = 3; echo <li>;
echo $a+$b; $c = test; echo Chestia . $i;
?> if($a==$b){ echo </li>;
</div> echo error; }
} else{ ?>
<div>
echo $c; </p>
5
}
</div> <ul>
?>
<li>Chestia 1</li>
</p>
<li>Chestia 2</li>
<p style=text-align:center> <li>Chestia 3</li>
test <li>Chestia 4</li>
</p> </ul>
FUNCIONAREA

[test.php] pe server
site.com/test.php
<strong>
<?php echo date(Y-m-d); ?>
</strong>
<strong>2016-12-20</strong>

<strong>
2016-12-20
</strong>
[test.php] trimis napoi clientului
ALT EXEMPLU
<?php
if(date(H) > 20)
$text = Nb; <html>
else <head>
$text = Sal!; <title>Exemplu PHP</title>
?> </head>
<html> <body>
<head> Sal!
<title>Exemplu PHP</title> </body>
</head> </html>
<body>
<?php echo $text; ?>
</body>
</html>
FUNCIA INCLUDE
despre.php contact.php
subsol.php
<html> <html>
Copyright 2016
<body> <body>
<strong>BitFall</strong>
<h2>Despre noi</h2> <h2>Contact</h2>
<p>Suntem o comp..</p> <form>.</form>
<?php <?php
include subsol.php; include subsol.php;
?> ?>
</body> </body>
</html> </html>

<html> <html>
<body> <body>
<h2>Despre noi</h2> <h2>Contact</h2>
<p>Suntem o comp..</p> <form>.</form>
Copyright 2016 <strong>BitFall</strong> Copyright 2016 <strong>BitFall</strong>
</body> </body>
</html> </html>
despre.php contact.php
GET I POST
GET: site.com/test.php?nume=test $_GET[nume] test

<?php
echo Numele: ;
Numele: test
echo $_GET[nume];
?>
POST: site.com/test.php
Date: $_POST[nume] test
nume=test $_POST[prenume] test2
prenume=test2
<?php
echo $_POST[nume] . ;
Numele: test echo $_POST[prenume];
?>
FUNCII PHP
<?php
function test($a){
$b = <strong>.$a.</strong>; <html>
return $b; <head>
} <title>Exemplu PHP</title>
?> </head>
<html> <body>
<head> <strong>Salutare!</strong>
<title>Exemplu PHP</title> </body>
</head> </html>
<body>
<?php echo test(Salutare!); ?>
</body>
</html>
NTREBRI...? :D

S-ar putea să vă placă și