27 Şubat 2017 Pazartesi

Php Kodları

Php Define

<!DOCTYPE html> <html> <body> <?php define("GREETING", «hELLO!"); function myTest() {      echo GREETING; }   myTest(); ?>  </body> </html>


Php If

<!DOCTYPE html> <html> <body> <?php $t = date("H"); echo "<p>The hour (of the server) is " . $t; echo ", and will give the following message:</p>"; if ($t <  "10") {      echo "Have a good morning!"; } elseif ($t <  "20") {      echo "Have a good day!"; } else {      echo "Have a good night!"; } ?>   </body> </html>


Php Switch



<!DOCTYPE html> <html> <body> <?php $favcolor = "red"; switch ($favcolor) {      case "red":          echo "Your favorite color is red!";          break;      case "blue":          echo "Your favorite color is blue!";          break;      case "green":          echo "Your favorite color is green!";          break;      default:          echo "Your favorite color is neither red, blue, or green!"; } ?>   </body> </html>


Php While do While


<!DOCTYPE html> <html> <body> <?php $x = 1;   while($x <= 5) {    echo "The number is: $x <br>";    $x++; } ?>   </body> </html>


<!DOCTYPE html> <html> <body> <?php $x = 1; do {      echo "The number is: $x <br>";      $x++; } while ($x <= 5); ?> </body> </html>

Php For ve ForEach


<!DOCTYPE html> <html> <body> <?php for ($x = 0; $x <= 10; $x++) {    echo "The number is: $x <br>"; } ?>   </body> </html>


<!DOCTYPE html> <html> <body> <?php $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) {    echo "$value <br>"; } ?>   </body> </html>


Php Fonksiyon

<!DOCTYPE html> <html> <body> <?php function sum($x, $y) {      $z = $x + $y;      return $z; } echo "5 + 10 = " . sum(5,10) . "<br>"; echo "7 + 13 = " . sum(7,13) . "<br>"; echo "2 + 4 = " . sum(2,4); ?> </body> </html>

<!DOCTYPE html> <html> <body> <?php function familyName($fname, $year) {      echo "$fname Refsnes. Born in $year <br>"; } familyName("Hege","1975"); familyName("Stale","1978"); familyName("Kai Jim","1983"); ?> </body> </html>

Php Dizler

<!DOCTYPE html> <html> <body> <?php $cars = array("Volvo", "BMW", "Toyota"); echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . "."; ?> </body> </html>

<!DOCTYPE html> <html> <body> <?php $cars = array("Volvo", "BMW", "Toyota"); $arrlength = count($cars); for($x = 0; $x <  $arrlength; $x++) {      echo $cars[$x];      echo "<br>"; } ?> </body> </html>


Php Hazır Fonksiyonlar



<!DOCTYPE html> <html> <body> <?php $cars = array("Volvo", "BMW", "Toyota"); sort($cars); $clength = count($cars); for($x = 0; $x <  $clength; $x++) {      echo $cars[$x];      echo "<br>"; } ?> </body> </html>


<!DOCTYPE html> <html> <body> <?php $numbers = array(4, 6, 2, 22, 11); rsort($numbers); $arrlength = count($numbers); for($x = 0; $x <  $arrlength; $x++) {      echo $numbers[$x];      echo "<br>"; } ?> </body> </html>

Php Super Global


<!DOCTYPE html> <html> <body> <?php echo $_SERVER['PHP_SELF']; echo "<br>"; echo $_SERVER['SERVER_NAME']; echo "<br>"; echo $_SERVER['HTTP_HOST']; echo "<br>"; echo $_SERVER['HTTP_REFERER']; echo "<br>"; echo $_SERVER['HTTP_USER_AGENT']; echo "<br>"; echo $_SERVER['SCRIPT_NAME']; ?> </body> </html>


Php Dosya Yazma


<!DOCTYPE html> <html> <body> <?php $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!"); echo fread($myfile,filesize("webdictionary.txt")); fclose($myfile); ?> </body> </html>


Diğer Php Konuları…


PHP Advanced
PHP Arrays Multi
PHP Date and Time
PHP Include
PHP File Handling
PHP File Open/Read
PHP File Create/Write
PHP File Upload
PHP Cookies
PHP Sessions
PHP Filters
PHP Filters Advanced
PHP Error Handling
PHP Exception
PHP - XML
PHP XML Parsers
PHP SimpleXML Parser
PHP SimpleXML - Get
PHP XML Expat
PHP XML DOM

PHP - AJAX
AJAX Intro
AJAX PHP
AJAX Database
AJAX XML
AJAX Live Search
AJAX RSS Reader
AJAX Poll

PHP Examples
PHP Examples
PHP Quiz
PHP Certificate
PHP Reference
PHP Array
PHP Calendar
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQLi
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Timezones