2014. szeptember 15., hétfő

A $_SERVER tömb kilistázása ciklussal

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 10.1 Looping through the $_SERVER array</title>
</head>
<body>
<div>
<?php
foreach ( $_SERVER as $key=>$value ) {
   print "\$_SERVER[\"$key\"] == $value<br/>";
}
?>
</div>
</body>
</html>

Eredmény:
$_SERVER["ALLUSERSPROFILE"] == C:\ProgramData
$_SERVER["APPDATA"] == C:\Users\G?bor\AppData\Roaming
$_SERVER["CommonProgramFiles"] == C:\Program Files (x86)\Common Files
$_SERVER["CommonProgramFiles(x86)"] == C:\Program Files (x86)\Common Files
$_SERVER["CommonProgramW6432"] == C:\Program Files\Common Files
$_SERVER["COMPUTERNAME"] == GABOR-PC
$_SERVER["ComSpec"] == C:\Windows\system32\cmd.exe
$_SERVER["FP_NO_HOST_CHECK"] == NO
$_SERVER["HOMEDRIVE"] == C:
$_SERVER["HOMEPATH"] == \Users\G?bor
$_SERVER["LOCALAPPDATA"] == C:\Users\G?bor\AppData\Local
$_SERVER["LOGONSERVER"] == \\GABOR-PC
$_SERVER["NB_EXEC_EXTEXECUTION_PROCESS_UUID"] == 2acf59eb-c72b-49b8-9f76-88308c4fcb17
$_SERVER["NUMBER_OF_PROCESSORS"] == 2
$_SERVER["OS"] == Windows_NT
$_SERVER["Path"] == C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;e:\Program Files (x86)\AOMEI Backupper Professional Edition 2.0;C:\Program Files\jEdit
$_SERVER["PATHEXT"] == .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
$_SERVER["PROCESSOR_ARCHITECTURE"] == x86
$_SERVER["PROCESSOR_ARCHITEW6432"] == AMD64
$_SERVER["PROCESSOR_IDENTIFIER"] == AMD64 Family 15 Model 107 Stepping 2, AuthenticAMD
$_SERVER["PROCESSOR_LEVEL"] == 15
$_SERVER["PROCESSOR_REVISION"] == 6b02
$_SERVER["ProgramData"] == C:\ProgramData
$_SERVER["ProgramFiles"] == C:\Program Files (x86)
$_SERVER["ProgramFiles(x86)"] == C:\Program Files (x86)
$_SERVER["ProgramW6432"] == C:\Program Files
$_SERVER["PSModulePath"] == C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
$_SERVER["PUBLIC"] == C:\Users\Public
$_SERVER["SESSIONNAME"] == Console
$_SERVER["SystemDrive"] == C:
$_SERVER["SystemRoot"] == C:\Windows
$_SERVER["TEMP"] == C:\Users\GBOR~1\AppData\Local\Temp
$_SERVER["TMP"] == C:\Users\GBOR~1\AppData\Local\Temp
$_SERVER["USERDOMAIN"] == Gabor-PC
$_SERVER["USERNAME"] == G?bor
$_SERVER["USERPROFILE"] == C:\Users\G?bor
$_SERVER["windir"] == C:\Windows
$_SERVER["windows_tracing_flags"] == 3
$_SERVER["windows_tracing_logfile"] == C:\BVTBin\Tests\installpackage\csilogfile.log
$_SERVER["PHP_SELF"] == E:\STY PHP in 24 Hours\Hour 10\listing10.01.php
$_SERVER["SCRIPT_NAME"] == E:\STY PHP in 24 Hours\Hour 10\listing10.01.php
$_SERVER["SCRIPT_FILENAME"] == E:\STY PHP in 24 Hours\Hour 10\listing10.01.php
$_SERVER["PATH_TRANSLATED"] == E:\STY PHP in 24 Hours\Hour 10\listing10.01.php
$_SERVER["DOCUMENT_ROOT"] ==
$_SERVER["REQUEST_TIME_FLOAT"] == 1410773489.2432
$_SERVER["REQUEST_TIME"] == 1410773489
Notice: Array to string conversion in E:\STY PHP in 24 Hours\Hour 10\listing10.01.php on line 12 $_SERVER["argv"] == Array
$_SERVER["argc"] == 1

9. fejezet gyakorlat megoldása: származtatott függvények

<!--listing9.gyak1
1. Hozzuk létre a Szamolo osztalyt, amely két egész számot tárol.
Írjunk hozzá egy kiszamol() nevű tagfüggvényt, amely kiírja a két számot a böngészőbe!
2. Hozzuk létre az Osszead osztályt, amely a Szamolo osztálytól örököl.
Írjuk át ennek kiszamol() tagfüggvényét úgy, hogy ennek a két számnak az összegét írja ki.
3. Hozzuk létre az Osszead alapján a Kivon osztályt!
-->
<?php
class Szamolo {

    function Szamolo( $egyik=2, $masik=3 ) {
        $this->egyik = $egyik;
        $this->masik = $masik;
    }
   
    function kiszamol() {
       print $this->egyik.", ".$this->masik;
    }
}

class Osszead extends Szamolo {
    function kiszamol() {
       print $this->egyik+$this->masik;
    }
}

class Kivon extends Szamolo {
    function kiszamol() {
       print $this->egyik-$this->masik;
    }
}

//ellenőrzés
$teszt = new Szamolo( 5,6 );
$teszt->kiszamol();
print "<BR \>";

$teszt1 = new Osszead( 5,6 );
$teszt1->kiszamol();
print "<BR \>";

$teszt2 = new Kivon( 5,6 );
$teszt2->kiszamol();
print "<BR \>";

?>

Eredmény:
5, 6
11
-1

Konstruktorok használata

<?php
class Item {
    private $name;

    function __construct( $name="item", $code=0 ) {
        $this->name = $name;
        $this->code = $code;
    }
   
    function getName() {
        return $this->name;
    }
}

class PriceItem extends Item {
    private $price;

    function __construct( $name, $code, $price ) {
        parent::__construct( $name, $code );
        $this->price = $price;
    }

    function getName() {
        return "(price) ".parent::getName();
    }
}

$item = new PriceItem( "widget", 5442, 5.20 );
print $item->getName();
// outputs "(price) widget"

?>

Eredmény:
(price) widget

Szülő osztály meghívása: parent

<?php
class Item {
    private $name;

    function __construct( $name="item", $code=0 ) {
        $this->name = $name;
        $this->code = $code;
    }
   
    function getName() {
        return $this->name;
    }
}

class PriceItem extends Item {
    private $price;

    function __construct( $name, $code, $price ) {
        parent::__construct( $name, $code );
        $this->price = $price;
    }

    function getName() {
        return "(price) ".parent::getName();
    }
}

$item = new PriceItem( "widget", 5442, 5.20 );
print $item->getName();
// outputs "(price) widget"

?>

Gyermekosztály által felülírt tagfüggvény

<?php
class Item {
    var $name;

    function Item( $name="item", $code=0 ) {
        $this->name = $name;
        $this->code = $code;
    }
   
    function getName() {
        return $this->name;
    }
}

class PriceItem extends Item {
    function getName() {
        return "(price) ".$this->name;
    }
}

$item = new PriceItem( "widget", 5442 );
print $item->getName();
// outputs "(price) widget"

?>

Eredmény:
(price) widget

Osztály származtatása

A származtatott osztály örökli az ős tulajdonságait és metódusait.

<?php
class Item {
    var $name;

    function Item( $name="item", $code=0 ) {
        $this->name = $name;
        $this->code = $code;
    }
   
    function getName() {
        return $this->name;
    }
}

class PriceItem extends Item {

}

$item = new PriceItem( "widget", 5442 );
print $item->getName();
// outputs "widget"

?>
Eredmény:
widget

Osztály nyilvános tulajdonságokkal

<?php
class Item {
    var $name;
    var $code;
    var $productString;

    function Item( $name="item", $code=0 ) {
        $this->code = $code;
        $this->setName( $name );
    }

    function getProductString() {
        return $this->productString;
    }
   
    function setName( $n ) {
        $this->name = $n;
        $this->productString = $this->name." ".$this->code;
    }

    function getName() {
        return $this->name;
    }
}

$item = new Item("widget", 5442);
print $item->getProductString();
// outputs "widget 5442"

print "<br />";

$item->name = "widget-upgrade";
print $item->getProductString();
// outputs "widget 5442", not "widget-upgrade 5442"
// Mivel nem a setName függvénnyel állítottuk be a nevét, nem annak megfelelő lesz.
?>
Eredmény:
widget 5442
widget 5442

Konstruktorral rendelkező osztály

A konstruktor függvény neve ugyanaz, mint az osztály neve.

<?php
class Item {
    var $name;

    function Item( $name="item" ) {
        $this->name = $name;
    }

    function setName( $n ) {
        $this->name = $n;
    }

    function getName() {
        return $this->name;
    }
}

$item = new Item("widget 5442");
print $item->getName();
// outputs "widget 5442"
?>
Eredmény:
widget 5442

Tulajdonság értékének módosítása függvénnyel.

A változónkat védetté thetjük, ha csak függvénnyel változtathatjuk az értékét és privátként definiáljuk. (Itt nem privát, de a módszert szemlélteti.)

<?php
class Item {
     var $name = "item";

     function setName( $n ) {
         $this->name = $n;
     }

     function getName() {
         return $this->name;
     }
}

$item = new Item();
$item->setName("widget 5442");
print $item->getName();
// outputs "widget 5442"
?>
Eredmény:
widget 5442

Objektumpéldány változójának és függvényének használata: $this

<?php
class Item {
     var $name = "item";

     function getName() {
         return $this->name;
     }
}

$item = new Item();
$item->name = "widget 5442";
print $item->getName();
// outputs "widget 5442"
?>
Eredmény:
widget 5442

Osztály változóval és tagfüggvénnyel

<?php
//Osztály változóval és tagfüggvénnyel
class Item {
     var $name = "item";

     function getName() {
         return "item";
     }
}

$item = new Item();
print $item->getName();
// outputs "item"
?>
Eredmény:
item

8. fejezet 2. gyakorlat: Számok oszlopba rendezése és igazítása printf() függvénnyel

PHP 8. fejezet 2. gyakorlat megoldása:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Lebegopontos szamok 2 tizedesre 20 szeles mezoben jobbra igazitva</title>
</head>
<body>
<?php
$lebegopontosok = array(  
    222.4,
    4,
    80.6,
    6548.9775
            );
print "<pre>";
foreach ( $lebegopontosok as $szam ) {
    printf( "%20.2f\n", $szam );
}
print "</pre>";
?>
</body>
</html>
Eredmény:
              222.40
                4.00
               80.60
             6548.98

Egy szöveg darabolása tokenekre: strtok()

Néha szükség van 1-1 hosszabb szöveg felosztására értelmes szakaszokká. Ilyenkor az eredeti szövegbe elválasztó karaktereket tesznek, amik alapján feldarabolhatjuk a kapott szöeget.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 8.3 Dividing a string into
        tokens with strtok()</title>
</head>
<body>
<div>
<?php
$test  = "http://p24.corrosive.co.uk/tk.php";
$test .= "?id=353&sec=44&user=harry&context=php";
//sajat sor:
print "$test<br/><br/>";
//
$delims = "?&";
$word = strtok( $test, $delims );
while ( is_string( $word ) ) {
   if ( $word ) {
       print "$word<br/>";
    }
    $word = strtok( $delims );
}
?>
</div>
</body>
</html>
Eredmény:
http://p24.corrosive.co.uk/tk.php?id=353&sec=44&user=harry&context=php

http://p24.corrosive.co.uk/tk.php
id=353
sec=44
user=harry
context=php

2014. szeptember 12., péntek

Formázott kiírás: printf

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 8.2 Using printf() to Format a List of Product Prices</title>
</head>
<body>
<?php
$products = array(   
            "Green armchair"=>222.4,
            "Candlestick"=>4,
            "Coffee table"=>80.6
            );
print "<pre>";
printf("%-20s%23s\n", "Name", "Price");
printf("%'-43s\n", "");
foreach ( $products as $key=>$val ) {
    printf( "%-20s%20.2f\n", $key, $val );
}
print "</pre>";
?>
</body>
</html>

Eredmény:

Name                                  Price
-------------------------------------------
Green armchair                    222.40
Candlestick                         4.00
Coffee table                       80.60

Típusok megadása

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 8.1 Demonstrating Some Type Specifiers</title>
</head>
<body>
<div>
<?php
$number = 543;
printf("Decimal: %d<br/>", $number );
printf("Binary: %b<br/>", $number );
printf("Double: %f<br/>", $number );
printf("Octal: %o<br/>", $number );
printf("String: %s<br/>", $number );
printf("Hex (lower): %x<br/>", $number );
printf("Hex (upper): %X<br/>", $number );
?>
</div>
</body>
</html>

Eredmény:

Decimal: 543
Binary: 1000011111
Double: 543.000000
Octal: 1037
String: 543
Hex (lower): 21f
Hex (upper): 21F

7. fejezet 2. gyakorlat megoldása

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//HU"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-->
<title>Listing 7.Gyak Filmek listázása tömbből filmtípusonként</title>
</!-->
<title>Listing 7.Gyak Filmek listazasa tombbol filmtipusonkent</title>
</head>
<body>
<div>
<?php
$karakterek = array (
            array (
                "Sci-Fi"=> "2001 Urodisszeia",
            ),
            array (
                "Sci-Fi"=> "A nyolcadik utas a halal",
            ),
            array (
                "Sci-Fi"=> "Csillagok haboruja",
            ),
            array (
                "Akcio" => "Az utolso cserkesz",
            ),
            array (
                "Romantikus" => "50 elso randi",
            )
        );

foreach ( $karakterek as $film ) {
    print "<p>";
    foreach ( $film as $kulcs=>$ertek ) {
        print "$kulcs: $ertek<br />";
        //print "$kulcs => $ertek<br />";
    }
    print "</p>";
}

?>
</div>
</body>
</html>

Eredmény:

Sci-Fi: 2001 Urodisszeia
Sci-Fi: A nyolcadik utas a halal
Sci-Fi: Csillagok haboruja
Akcio: Az utolso cserkesz
Romantikus: 50 elso randi

7 fejezet 1. gyakorlat megoldása

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//HU"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-->
<title>Listing 7.Gyak Filmek listázása tömbből filmtípusonként</title>
</!-->
<title>Listing 7.Gyak Filmek listazasa tombbol filmtipusonkent</title>
</head>
<body>
<div>
<?php
$karakterek = array (
            array (
                "filmcim"=> "2001 Urodisszeia",
                "filmtipus" => "Sci-Fi",
            ),
            array (
                "filmcim"=> "A nyolcadik utas a halal",
                "filmtipus" => "Sci-Fi",
            ),
            array (
                "filmcim"=> "Csillagok haboruja",
                "filmtipus" => "Sci-Fi",
            ),
            array (
                "filmcim" => "Az utolso cserkesz",
                "filmtipus" => "Akcio",
            ),
            array (
                "filmcim" => "50 elso randi",
                "filmtipus" => "Romantikus",
            )
        );

foreach ( $karakterek as $film ) {
    print "<p>";
    foreach ( $film as $kulcs=>$ertek ) {
        print "$kulcs: $ertek<br />";
    }
    print "</p>";
}

?>
</div>
</body>
</html>

Eredmény:

filmcim: 2001 Urodisszeia
filmtipus: Sci-Fi
filmcim: A nyolcadik utas a halal
filmtipus: Sci-Fi
filmcim: Csillagok haboruja
filmtipus: Sci-Fi
filmcim: Az utolso cserkesz
filmtipus: Akcio
filmcim: 50 elso randi
filmtipus: Romantikus

Tömb vagy más összetett típus értékeinek kiírása: print_r

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 7.4 Testing the print_r() Function</title>
</head>
<body>
<div>
<?php
$characters = array (
            array (
                "name"=> "bob",
                "occupation" => "superhero",
            ),
            array (
                "name" => "sally",
                "occupation" => "superhero",
            )
        );

print_r( $characters );

/*
prints:
Array
(
    [0] => Array
        (
            [name] => bob
            [occupation] => superhero
        )

    [1] => Array
        (
            [name] => sally
            [occupation] => superhero
        )

)
*/

?>
</div>
</body>
</html>

Eredmény:

Array ( [0] => Array ( [name] => bob [occupation] => superhero ) [1] => Array ( [name] => sally [occupation] => superhero ) )

A foreach többdimenziós tömbökre is működik

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 7.3 Looping Through a Multidimensional Array</title>
</head>
<body>
<div>
<?php
$characters = array (
            array (
                "name"=> "bob",
                "occupation" => "superhero",
                "age" => 30,
                "specialty" =>"x-ray vision"
            ),
            array (
                "name" => "sally",
                "occupation" => "superhero",
                "age" => 24,
                "specialty" => "superhuman strength"
            ),
            array (
                "name" => "mary",
                "occupation" => "arch villain",
                "age" => 63,
                "specialty" =>"nanotechnology"
            )
        );

foreach ( $characters as $val ) {
    print "<p>";
    foreach ( $val as $key=>$final_val ) {
        print "$key: $final_val<br />";
    }
    print "</p>";
}

?>
</div>
</body>
</html>

Eredmény:

name: bob
occupation: superhero
age: 30
specialty: x-ray vision
name: sally
occupation: superhero
age: 24
specialty: superhuman strength
name: mary
occupation: arch villain
age: 63
specialty: nanotechnology

Foreach: a tömblistázó szuperfegyver


A foreeach anélkül megy végig a tömb elemein, hogy tudnunk kéne az elemek számát vagy nevét!

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 7.2 Looping Through an Associative Array with foreach</title>
</head>
<body>
<div>
<?php
$character = array (
            "name" => "bob",
            "occupation" => "superhero",
            "age" => 30,
            "special power" => "x-ray vision"
            );
foreach ( $character as $key=>$val ) {
    print "$key = $val<br />";
}

?>
</div>
</body>
</html>
Eredmény:
name = bob
occupation = superhero
age = 30
special power = x-ray vision

PHP egyszerű többdimenziós tömb használata: array(array()...array())

A névvel indexelt tömböket asszociatív tömböknek hívjuk. Ilyen a példabeli belső tömb.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 7.1 Defining a Multidimensional Array</title>
</head>
<body>
<div>
<?php

$characters = array (
            array (
                "name"=> "bob",
                "occupation" => "superhero",
                "age" => 30,
                "specialty" =>"x-ray vision"
            ),
            array (
                "name" => "sally",
                "occupation" => "superhero",
                "age" => 24,
                "specialty" => "superhuman strength"
            ),
            array (
                "name" => "mary",
                "occupation" => "arch villain",
                "age" => 63,
                "specialty" =>"nanotechnology"
            )
        );

                $print = print $characters[0]["age"];
// prints "superhero"
?>
</div>
</body>
</html>

Eredmény:
30

PHP szövegformázó függvények

Az alábbi példában paraméterként adhatók meg a formázó függvények nevei is. Vastagbetűs, kicsinyített és dőlt betűs.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.16</title>
</head>
<body>
<div>
<?php

function tagWrap( $tag, $txt, $func="" ) {
    if ( function_exists( $func ) )
        $txt = $func( $txt );
    return "<$tag>$txt</$tag>\n";
}

function subscript( $txt ) {
    return "<sub>$txt</sub>";
}

print tagWrap('b', 'make me bold');
// <b>make me bold</b>

print tagWrap('i', 'shrink me too', "subscript");
// <i><sub>shrink me too</sub></i>

print tagWrap('i', 'make me italic and quote me',
    create_function('$txt', 'return "&quot;$txt&quot;";'));
// <i>&quot;make me italic and quote me&quot;</i>

?>
</div>
</body>
</html>

Eredmény:

make me bold shrink me too "make me italic and quote me"

Függvény visszatérési értékkel: return

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.15</title>
</head>
<body>
<div>
<?php
$my_anon = create_function( '$a, $b', 'return $a+$b;' );
print $my_anon( 3, 9 );

// prints 12
?>
</div>
</body>
</html>

Eredmény:

12

2014. szeptember 11., csütörtök

PHP cím szerinti paraméterátadás: & jellel

Érdekes, hogy csak a függvénydeklarációban van megadva, hogy cím szerinti a paraméter.
pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.14</title>
</head>
<body>
<div>
<?php
function addFive( &$num ) {
     $num += 5;
}
$orignum = 10;
addFive( $orignum );
print( $orignum );
?>
</div>
</body>
</html>
Eredmény:

15

Az alapértelmezett paraméterátadás érték szerint történik

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.13</title>
</head>
<body>
<div>
<?php
function addFive( $num ) {
     $num += 5;
}
$orignum = 10;
addFive( $orignum );
print( $orignum );
?>
</div>
</body>
</html>
Eredmény:

10

PHP függvény paraméter alapértelmezett érték használata

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.12</title>
</head>
<body>
<?php
function headingWrap( $txt, $size=3 ) {
    print "<h$size>$txt</h$size>";
}
headingWrap("Book title", 1);
headingWrap("Chapter title",2);
headingWrap("Section heading");
headingWrap("Another Section heading");
?>
</body>
</html>
Eredmény:

Book title

Chapter title

Section heading

Another Section heading

PHP static használata

A static olyan változót (vagy metódust) jelöl, ami a függvényektől, objektumoktól független, tehát az adott osztályban csak 1 van belőle. Osztályváltozó vagy osztálymetódus néven is emlgethetik. Az alap értékadás a létrehozásakor történik, ezután már átugorja ezt a sort a további hívásokkor.
pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.10 Using the static Statement</title>
</head>
<body>
<div>
<?php
function numberedHeading( $txt ) {
     static $num_of_calls = 0;
     $num_of_calls++;
     print "<h1>$num_of_calls. $txt</h1>";
}
numberedHeading("Widgets");
print "<p>We build a fine range of widgets</p>";
numberedHeading("Doodads");
print "<p>Finest in the world</p>";
?>
</div>
</body>
</html>
Eredmény:

1. Widgets

We build a fine range of widgets

2. Doodads

Finest in the world

A global kulcsszóval elérhetjük a globális változókat a függvényekben is

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.8</title>
</head>
<body>
<div>
<?php
$life=42;

function meaningOfLife() {
     global $life;
     print "The meaning of life is $life<br />";
}
meaningOfLife();
?>
</div>
</body>
</html>
Eredmény:

The meaning of life is 42

Nincs alapértelmezett elérés a globális változókhoz a függvényekben

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.7 No Default Access to Globals in Functions</title>
</head>
<body>
<div>
<?php
$life = 42;
function meaningOfLife() {
     print "The meaning of life is $life<br />";
}
meaningOfLife();
?>
</div>
</body>
</html>
Eredmény:

Notice: Undefined variable: life in E:\STY PHP in 24 Hours\Hour 06\listing6.07.php on line 13 The meaning of life is

A helyi változók nem érhetők el kívülről

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.6 Local Variable Unavailable Outside a Function</title>
</head>
<body>
<div>
<?php
function test() {
     $testvariable = "this is a test variable";
}
print "test variable: $testvariable<br/>";
?>
</div>
</body>
</html>
Eredmény:

Notice: Undefined variable: testvariable in E:\STY PHP in 24 Hours\Hour 06\listing6.06.php on line 14 test variable:

Dinamikus függvényhívás: futás közben dől el a hívandó függvény neve

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.5 Calling a Function Dynamically</title>
</head>
<body>
<div>
<?php
function sayHello() {
    print "hello<br />";
}
$function_holder = "sayHello";
$function_holder();
?>
</div>
</body>
</html>
Eredmény:

hello

PHP függvény visszatérési értékkel

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.4 A Function That Returns a Value</title>
</head>
<body>
<div>
<?php
function addNums( $firstnum, $secondnum ) {
     $result = $firstnum + $secondnum;
     return $result;
}
print addNums(3,5);
// will print "8"
?>
</div>
</body>
</html>

Eredmény:

8

PHP paraméteres függvény készítése

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.3 Declaring a Function That Requires Arguments</title>
</head>
<body>
<div>
<?php
function printBR( $txt ) {
     print ("$txt<br />\n");
}
printBR("This is a line");
printBR("This is a new line");
printBR("This is yet another line");
?>
</div>
</body>
</html>
Eredmény:

This is a line
This is a new line
This is yet another line

PHP függvény deklarálása

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.2 Declaring a Function</title>
</head>
<body>
<div>
<?php
function bighello() {
     print "<h1>HELLO!</h1>";
}
bighello();
?>
</div>
</body>
</html>
Eredmény:

HELLO!

PHP beépített abs függvény használata

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 6.1 Calling the Built-in abs() function</title>
</head>
<body>
<div>
<?php
$num = -321;
$newnum = abs( $num );
print $newnum;
// prints "321"
?>
</div>
</body>
</html>
Eredmény:

321

HTML használata 1 kód-blokk belsejében

Vagyis a PHP vége, kezdete jelzés közé írhatunk HTML kódot.
pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.14 Returning to HTML Mode Within a Code Block</title>
</head>
<body>
<div>
<?php
$display_prices = true;

if ( $display_prices ) {
?>
    <table border="1">
    <tr><td colspan="3">todays prices in dollars</td></tr><tr>
    <td>14</td><td>32</td><td>71</td>
    </tr></table>
<?php
}

?>
</div>
</body>
</html>
Eredmény:

todays prices in dollars
143271

Egy kód-blokk tartalmazhat több kiírást - formázáshoz

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.13 A Code Block Containing Multiple print() statements</title>
</head>
<body>
<div>
<?php
$display_prices = true;

if ( $display_prices ) {
    print "<table border=\"1\">";
    print "<tr><td colspan=\"3\">";
    print "todays prices in dollars";
    print "</td></tr><tr>";
    print "<td>14</td><td>32</td><td>71</td>";
    print "</tr></table>";
}

?>
</div>
</body>
</html>
Eredmény:

todays prices in dollars
143271

Egymásba ágyazott ciklusok

A külső ciklus minden számlálása között lefut 1 teljes belső ciklus.
Pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.12 Nesting Two for Loops</title>
</head>
<body>
<div>
<?php
print "<table border=\"0\">\n";
for ( $y=1; $y<=12; $y++ ) {
    print "<tr>\n";
    for ( $x=1; $x<=12; $x++ ) {
        print "\t<td>";
        print ($x*$y);
        print "</td>\n";
    }
    print "</tr>\n";
}
print "</table>";
?>
</div>
</body>
</html>
Eredmény:

1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 12 15 18 21 24 27 30 33 36
4 8 12 16 20 24 28 32 36 40 44 48
5 10 15 20 25 30 35 40 45 50 55 60
6 12 18 24 30 36 42 48 54 60 66 72
7 14 21 28 35 42 49 56 63 70 77 84
8 16 24 32 40 48 56 64 72 80 88 96
9 18 27 36 45 54 63 72 81 90 99 108
10 20 30 40 50 60 70 80 90 100 110 120
11 22 33 44 55 66 77 88 99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144

continue: folytatás a következő ciklustól

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.11 Using the continue Statement</title>
</head>
<body>
<div>
<?php
$counter = -4;
for ( ;  $counter <= 10; $counter++ ) {
    if ( $counter == 0 ) {
        continue;
    }
    $temp = 4000/$counter;
    print "4000 divided by $counter is... $temp<br />";
}
?>
</div>
</body>
</html>
Eredmény:

4000 divided by -4 is... -1000
4000 divided by -3 is... -1333.3333333333
4000 divided by -2 is... -2000
4000 divided by -1 is... -4000
4000 divided by 1 is... 4000
4000 divided by 2 is... 2000
4000 divided by 3 is... 1333.3333333333
4000 divided by 4 is... 1000
4000 divided by 5 is... 800
4000 divided by 6 is... 666.66666666667
4000 divided by 7 is... 571.42857142857
4000 divided by 8 is... 500
4000 divided by 9 is... 444.44444444444
4000 divided by 10 is... 400

break: kiugrás a ciklusból

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.10 Using the break Statement</title>
</head>
<body>
<div>
<?php
$counter = -4;
for ( ; $counter <= 10; $counter++ ) {
    if ( $counter == 0 ) {
        break;
    }
    $temp = 4000/$counter;
    print "4000 divided by $counter is... $temp<br />";
}
?>
</div>
</body>
</html>
Eredmény:

4000 divided by -4 is... -1000
4000 divided by -3 is... -1333.3333333333
4000 divided by -2 is... -2000
4000 divided by -1 is... -4000

A for ciklus

Formája:
for ( kezdőérték; feltétel; számolási parancs) {
   }

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.8 Using the for Statement</title>
</head>
<body>
<div>
<?php
for ( $counter=1; $counter<=12; $counter++ ) {
    print "$counter times 2 is ".($counter*2)."<br />";
}
?>
</div>
</body>
</html>
Eredmény:
1 times 2 is 2
2 times 2 is 4
3 times 2 is 6
4 times 2 is 8
5 times 2 is 10
6 times 2 is 12
7 times 2 is 14
8 times 2 is 16
9 times 2 is 18
10 times 2 is 20
11 times 2 is 22
12 times 2 is 24

PHP do...while ciklus

Hátultesztelő ciklus, addig fut, amíg igaz a feltétel. Egyszer mindenképp lefut!

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.7 The do...while Statement</title>
</head>
<body>
<div>
<?php
$num = 221;
do {
    print "Execution number: $num<br />\n";
    $num++;
} while ( $num > 200 && $num < 400 );
?>
</div>
</body>
</html>


Eredmény:

Execution number: 221
Execution number: 222
Execution number: 223
Execution number: 224
Execution number: 225
Execution number: 226
Execution number: 227
Execution number: 228
Execution number: 229
Execution number: 230
Execution number: 231
Execution number: 232
Execution number: 233
Execution number: 234
Execution number: 235
Execution number: 236
Execution number: 237
Execution number: 238
Execution number: 239
Execution number: 240
Execution number: 241
Execution number: 242
Execution number: 243
Execution number: 244
Execution number: 245
Execution number: 246
Execution number: 247
Execution number: 248
Execution number: 249
Execution number: 250
Execution number: 251
Execution number: 252
Execution number: 253
Execution number: 254
Execution number: 255
Execution number: 256
Execution number: 257
Execution number: 258
Execution number: 259
Execution number: 260
Execution number: 261
Execution number: 262
Execution number: 263
Execution number: 264
Execution number: 265
Execution number: 266
Execution number: 267
Execution number: 268
Execution number: 269
Execution number: 270
Execution number: 271
Execution number: 272
Execution number: 273
Execution number: 274
Execution number: 275
Execution number: 276
Execution number: 277
Execution number: 278
Execution number: 279
Execution number: 280
Execution number: 281
Execution number: 282
Execution number: 283
Execution number: 284
Execution number: 285
Execution number: 286
Execution number: 287
Execution number: 288
Execution number: 289
Execution number: 290
Execution number: 291
Execution number: 292
Execution number: 293
Execution number: 294
Execution number: 295
Execution number: 296
Execution number: 297
Execution number: 298
Execution number: 299
Execution number: 300
Execution number: 301
Execution number: 302
Execution number: 303
Execution number: 304
Execution number: 305
Execution number: 306
Execution number: 307
Execution number: 308
Execution number: 309
Execution number: 310
Execution number: 311
Execution number: 312
Execution number: 313
Execution number: 314
Execution number: 315
Execution number: 316
Execution number: 317
Execution number: 318
Execution number: 319
Execution number: 320
Execution number: 321
Execution number: 322
Execution number: 323
Execution number: 324
Execution number: 325
Execution number: 326
Execution number: 327
Execution number: 328
Execution number: 329
Execution number: 330
Execution number: 331
Execution number: 332
Execution number: 333
Execution number: 334
Execution number: 335
Execution number: 336
Execution number: 337
Execution number: 338
Execution number: 339
Execution number: 340
Execution number: 341
Execution number: 342
Execution number: 343
Execution number: 344
Execution number: 345
Execution number: 346
Execution number: 347
Execution number: 348
Execution number: 349
Execution number: 350
Execution number: 351
Execution number: 352
Execution number: 353
Execution number: 354
Execution number: 355
Execution number: 356
Execution number: 357
Execution number: 358
Execution number: 359
Execution number: 360
Execution number: 361
Execution number: 362
Execution number: 363
Execution number: 364
Execution number: 365
Execution number: 366
Execution number: 367
Execution number: 368
Execution number: 369
Execution number: 370
Execution number: 371
Execution number: 372
Execution number: 373
Execution number: 374
Execution number: 375
Execution number: 376
Execution number: 377
Execution number: 378
Execution number: 379
Execution number: 380
Execution number: 381
Execution number: 382
Execution number: 383
Execution number: 384
Execution number: 385
Execution number: 386
Execution number: 387
Execution number: 388
Execution number: 389
Execution number: 390
Execution number: 391
Execution number: 392
Execution number: 393
Execution number: 394
Execution number: 395
Execution number: 396
Execution number: 397
Execution number: 398
Execution number: 399

PHP while ciklus

Elöltesztelő ciklus, addig fut, amíg a feltétel igaz.

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.6 A while Statement</title>
</head>
<body>
<div>
<?php
$counter = 1;
while ( $counter <= 12 ) {
    print "$counter times 2 is ".($counter*2)."<br />";
    $counter++;
}
?>
</div>
</body>
</html>


Eredmény:
We are sorry that we have not met your expectations

feltétel ?: - "if függyvény"

Régebbi programnyelvekben és SQL-ben if függvényként ismeretes. Itt ternális (háromoperandusú) műveletjelnek hívjuk. lényege, hogy a feltételtől függően az igaz vagy hamis értéke szerint állítja be a visszaadott értéket.

pl:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.5 Using the ? Operator</title>
</head>
<body>
<div>
<?php
$satisfied = "no";

$pleased = "We are pleased that you are happy with our service";
$sorry = "We are sorry that we have not met your expectations";

$text = ( $satisfied=="very" )?$pleased:$sorry;
print "$text";
?>
</div>
</body>
</html>

Eredmény:
We are sorry that we have not met your expectations

Több ágú elágazás 1 értéktől függően: switch

A vizsgált érték csak egyszerű típusú lehet. (Objektum, tömb... nem.)
Alakja:

switch ( kifejezés )
{
case érték1:
<utasítás>
break;
case érték2:
<utasítás>
break;
default:
 <utasítás>
break; //ez elvileg nem kötelező, de biztonságosabb, ha van
}

pl:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.4 A switch Statement</title>
</head>
<body>
<div>
<?php
$satisfied = "no";
switch ( $satisfied ) {
    case "very":
        print "We are pleased that you are happy with our service";
        break;
    case "no":
        print "We are sorry that we have not met your expectations";
        break;
    default:
        print "Please take a moment to rate our service";
}
?>
</div>
</body>
</html>

Eredmény:
We are sorry that we have not met your expectations

2-nél több ágú elágazás: if, elseif...elseif, else


A szerkezet a következő:
if ( feltétel ) {
    } else if ( feltétel ) {
   } else {
    }

pl.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.3 An if statement That Uses else and else if</title>
</head>
<body>
<div>
<?php
$satisfied = "no";
if ( $satisfied == "very" ) {
    print "We are pleased that you are happy with our service";
    // register customer satisfaction in some way
} else if ( $satisfied == "no" ) {
    print "We are sorry that we have not met your expectations";
    // request further feedback
} else {
    print "Please take a moment to rate our service";
    // present pulldown
}
?>
</div>
</body>
</html>


Eredmény:
We are sorry that we have not met your expectations

2014. szeptember 10., szerda

2 ágú elágazás - if ,,, else

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.2 An if Statement That Uses else</title>
</head>
<body>
<div>
<?php
// $satisfied = "very";
if ( $satisfied == "very" ) {
    print "We are pleased that you are happy with our service";
    // register customer satisfaction in some way
} else {
    print "Please take a moment to rate our service";
    // present pulldown
}
?>
</div>
</body>
</html>


Eredmény:
Notice: Undefined variable: satisfied in E:\STY PHP in 24 Hours\Hour 05\listing5.02.php on line 12 Please take a moment to rate our service

Egyszerű elágazás: if

Elágaztathatjuk a végrehajtást feltételtől függően.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.1 An if Statement</title>
</head>
<body>
<div>
<?php
$satisfied = "very";
if ( $satisfied == "very" ) {
    print "We are pleased that you are happy with our service";
    // register customer satisfaction in some way
}
?>
</div>
</body>
</html>


Eredmény:
We are pleased that you are happy with our service

PHP konstansok - define()

A konstansok megadása egyszerű:  a define() fügyvénybe írjuk a nevét és az értékét:
pl: define ( "USER", "Gerald" );


<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 4.4 Defining a Constant</title>
</head>
<body>
<div>
<?php
define ( "USER", "Gerald" );
print "Welcome ".USER;
?>
</div>
</body>
</html>

Eredmény:
Welcome Gerald

PHP Casting - megjelenés megváltoztatása

Kasztolás: A változó megjelenítését változtatjuk, de az értékét és típusát nem! Sajnos a Neten eléggé pongyola illetve pontatlan, sőt esetenként rossz meghatározások szerepelnek a casting fogalmára. Néhol típuskonverziónak írják, ami abszolút rossz megfogalmazás, mert az adott változónak nem változtatjuk meg a típusát, csak a megjelenítését! Nézzük meg a példát és egyből megértjük miről van szó.

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 4.3 Casting a Variable</title>
</head>
<body>
<div>
<?php
$undecided = 3.14;
$holder = ( double ) $undecided;
print gettype( $holder ) ; // double
print " -- $holder<br />";   // 3.14
$holder = ( string ) $undecided;
print gettype( $holder );  // string
print " -- $holder<br />";   // 3.14
$holder = ( int ) $undecided;
print gettype( $holder );  // integer
print " -- $holder<br />";   // 3
$holder = ( double ) $undecided;
print gettype( $holder );  // double
print " -- $holder<br />";   // 3.14
$holder = ( bool ) $undecided;
print gettype( $holder );  // boolean
print " -- $holder<br />";   // 1
?>
</div>
</body>
</html>


Eredmény:

double -- 3.14
string -- 3.14
integer -- 3
double -- 3.14
boolean -- 1

Változók típusainak megváltoztatása, settype()

Megváltoztathatjuk egy változó típusát a settype() függvénnyel/utasítással

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 4.2 Changing the Type of a Variable with settype()</title>
</head>
<body>
<div>
<?php
$undecided = 3.14;
print gettype( $undecided ); // double
print " -- $undecided<br />";  // 3.14
settype( $undecided, string );
print gettype( $undecided ); // string
print " -- $undecided<br />";  // 3.14
settype( $undecided, integer );
print gettype( $undecided ); // integer
print " -- $undecided<br />";  // 3
settype( $undecided, double );
print gettype( $undecided ); // double
print " -- $undecided<br />";  // 3.0
settype( $undecided, boolean );
print gettype( $undecided ); // boolean
print " -- $undecided<br />";  // 1
?>
</div>
</body>
</html>


Eredmény:

double -- 3.14
Notice: Use of undefined constant string - assumed 'string' in E:\STY PHP in 24 Hours\Hour 04\listing4.2.php on line 14 string -- 3.14
Notice: Use of undefined constant integer - assumed 'integer' in E:\STY PHP in 24 Hours\Hour 04\listing4.2.php on line 17 integer -- 3
Notice: Use of undefined constant double - assumed 'double' in E:\STY PHP in 24 Hours\Hour 04\listing4.2.php on line 20 double -- 3
Notice: Use of undefined constant boolean - assumed 'boolean' in E:\STY PHP in 24 Hours\Hour 04\listing4.2.php on line 23 boolean -- 1

Vegyük észre, hogy a konverzió közben értékvesztés jöhet létre!

PHP alap típusok, gettype( )

Típus nélkül is adhatunk értékeket a változóknak, akkor majd a PHP ad nekik típust!

Az értékadás a következő:
$testing = 5;

Egy típustesztelés:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 4.1 Testing the Type of a Variable</title>
</head>
<body>
<div>
<?php
$testing; // declare without assigning
print gettype( $testing ); // NULL
print "<br />";
$testing = 5;
print gettype( $testing ); // integer
print "<br />";
$testing = "five";
print gettype( $testing ); // string
print "<br />";
$testing = 5.0;
print gettype( $testing ); // double
print "<br />";
$testing = true;
print gettype( $testing ); // boolean
print "<br />";
?>
</div>
</body>
</html>


Eredmény:

Notice: Undefined variable: testing in E:\STY PHP in 24 Hours\Hour 04\listing4.1.php on line 12 NULL
integer
string
double
boolean

PHP script beágyazása HTML fájlba

3 féle módon ágyazhatunk be:
A jelpárok közé kell írni a kódot:

 <?php
  ...
 ?>

<script language="php">
                ...
                </script>

 <%
       ...
        /%>

Példa:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>Listing 3.2 A PHP Script Including HTML</title>
    </head>
    <body>
        <div><b>
                <?php
                print "hello world";
                ?>
            </b></div>
        <p>
    <!--; Allow ASP-style <% %> tags.-->
            <!--; http://php.net/asp-tags-->
            <!--asp_tags = Off-->
        </p> <%
        print "szia"
        //ez nem megy nalam
        /%>
        <p>
        </p>
        <script language="php">
                print "scriptes"
                </script>
    </body>
</html>


A kimenet:
hello world

<% print "szia" //ez nem megy nalam /%>

scriptes

PHP Hello World!

A szövegk kiírása a print utasítással történik: (Mint a Basic-ben)
<?php
print "Hello World!";
?>

Az első lépések

Miután feltelepítettük és elindítottuk a web szerverünket és beállítottuk a PHP értelmezőnket a Netbeans-ben, elkezdhetjük a gyakorlást.
A PHP hasonlít sok mai programnyelvre, ezért az alap programozási tudásról nem írok, feltételezem, hogy ismerünk már egy nyelvet.
Az első, amit érdemes tudni, az a phpinfo:

<?php
phpinfo();
?>


Ez a programocska kilistázza a rendszerünkről a főbb tudnivalókat.
Egy ilyesmi infot kapunk eredményül:
phpinfo() PHP Version => 5.4.19 System => Windows NT GABOR-PC 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586 Build Date => Aug 21 2013 01:07:08 Compiler => MSVC9 (Visual C++ 2008) Architecture => x86 Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo" Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => C:\Windows Loaded Configuration File => E:\xampp\php\php.ini Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) PHP API => 20100412 PHP Extension => 20100525 Zend Extension => 220100525 Zend Extension Build => API220100525,TS,VC9 PHP Extension Build => API20100525,TS,VC9 Debug Build => no Thread Safety => enabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, phar Registered Stream Socket Transports => tcp, udp Registered Stream Filters => convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.* This program makes use of the Zend Scripting Language Engine: Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies _______________________________________________________________________ Configuration bcmath BCMath support => enabled Directive => Local Value => Master Value bcmath.scale => 0 => 0 bz2 BZip2 Support => Enabled Stream Wrapper support => compress.bzip2:// Stream Filter support => bzip2.decompress, bzip2.compress BZip2 Version => 1.0.6, 6-Sept-2010 calendar Calendar support => enabled Core PHP Version => 5.4.19 Directive => Local Value => Master Value allow_url_fopen => On => On allow_url_include => Off => Off always_populate_raw_post_data => Off => Off arg_separator.input => & => & arg_separator.output => & => & asp_tags => Off => Off auto_append_file => no value => no value auto_globals_jit => On => On auto_prepend_file => no value => no value browscap => \xampp\php\extras\browscap.ini => \xampp\php\extras\browscap.ini default_charset => no value => no value default_mimetype => text/html => text/html disable_classes => no value => no value disable_functions => no value => no value display_errors => STDOUT => STDOUT display_startup_errors => On => On doc_root => no value => no value docref_ext => no value => no value docref_root => no value => no value enable_dl => On => On enable_post_data_reading => On => On error_append_string => no value => no value error_log => \xampp\php\logs\php_error_log => \xampp\php\logs\php_error_log error_prepend_string => no value => no value error_reporting => 32767 => 32767 exit_on_timeout => Off => Off expose_php => On => On extension_dir => \xampp\php\ext => \xampp\php\ext file_uploads => On => On highlight.comment => #FF8000 => #FF8000 highlight.default => #0000BB => #0000BB highlight.html =>#000000 => #000000 highlight.keyword => #007700 => #007700 highlight.string => #DD0000 => #DD0000 html_errors => Off => Off ignore_repeated_errors => Off => Off ignore_repeated_source => Off => Off ignore_user_abort => Off => Off implicit_flush => On => On include_path => .;\xampp\php\PEAR => .;\xampp\php\PEAR log_errors => On => On log_errors_max_len => 1024 => 1024 mail.add_x_header => Off => Off mail.force_extra_parameters => no value => no value mail.log => no value => no value max_execution_time => 0 => 0 max_file_uploads => 20 => 20 max_input_nesting_level => 64 => 64 max_input_time => -1 => -1 max_input_vars => 1000 => 1000 memory_limit => 128M => 128M open_basedir => no value => no value output_buffering => 0 => 0 output_handler => no value => no value post_max_size => 8M => 8M precision => 14 => 14 realpath_cache_size => 16K => 16K realpath_cache_ttl => 120 => 120 register_argc_argv => On => On report_memleaks => On => On report_zend_debug => Off => Off request_order => GP => GP sendmail_from => no value => no value sendmail_path => \xampp\mailtodisk\mailtodisk.exe => \xampp\mailtodisk\mailtodisk.exe serialize_precision => 100 => 100 short_open_tag => Off => Off SMTP => localhost => localhost smtp_port => 25 => 25 sql.safe_mode => Off => Off track_errors => On => On unserialize_callback_func => no value => no value upload_max_filesize => 2M => 2M upload_tmp_dir => \xampp\tmp => \xampp\tmp user_dir => no value => no value user_ini.cache_ttl => 300 => 300 user_ini.filename => .user.ini => .user.ini variables_order => GPCS => GPCS windows.show_crt_warning => Off => Off xmlrpc_error_number => 0 => 0 xmlrpc_errors => Off => Off zend.detect_unicode => On => On zend.enable_gc => On => On zend.multibyte => Off => Off zend.script_encoding => no value => no value ctype ctype functions => enabled curl cURL support => enabled cURL Information => 7.30.0 Age => 3 Features AsynchDNS => Yes Debug => No GSS-Negotiate => Yes IDN => No IPv6 => Yes Largefile => Yes NTLM => Yes SPNEGO => Yes SSL => Yes SSPI => Yes krb4 => No libz => Yes CharConv => No Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp Host => i386-pc-win32 SSL Version => OpenSSL/0.9.8y ZLib Version => 1.2.7 libSSH Version => libssh2/1.4.2 date date/time support => enabled "Olson" Timezone Database Version => 2013.4 Timezone Database => internal Default timezone => Europe/Berlin Directive => Local Value => Master Value date.default_latitude => 31.7667 => 31.7667 date.default_longitude => 35.2333 => 35.2333 date.sunrise_zenith => 90.583333 => 90.583333 date.sunset_zenith => 90.583333 => 90.583333 date.timezone => Europe/Berlin => Europe/Berlin dom DOM/XML => enabled DOM/XML API Version => 20031129 libxml Version => 2.7.8 HTML Support => enabled XPath Support => enabled XPointer Support => enabled Schema Support => enabled RelaxNG Support => enabled ereg Regex Library => Bundled library enabled exif EXIF Support => enabled EXIF Version => 1.4 $Id$ Supported EXIF Version => 0220 Supported filetypes => JPEG,TIFF Directive => Local Value => Master Value exif.decode_jis_intel => JIS => JIS exif.decode_jis_motorola => JIS => JIS exif.decode_unicode_intel => UCS-2LE => UCS-2LE exif.decode_unicode_motorola => UCS-2BE => UCS-2BE exif.encode_jis => no value => no value exif.encode_unicode => ISO-8859-15 => ISO-8859-15 filter Input Validation and Filtering => enabled Revision => $Id: 6496ccdb6a0a4792ced7f000203981dd4afe3657 $ Directive => Local Value => Master Value filter.default => unsafe_raw => unsafe_raw filter.default_flags => no value => no value ftp FTP support => enabled gd GD Support => enabled GD Version => bundled (2.1.0 compatible) FreeType Support => enabled FreeType Linkage => with freetype FreeType Version => 2.4.10 GIF Read Support => enabled GIF Create Support => enabled JPEG Support => enabled libJPEG Version => 8 PNG Support => enabled libPNG Version => 1.2.50 WBMP Support => enabled XPM Support => enabled libXpm Version => 30411 XBM Support => enabled Directive => Local Value => Master Value gd.jpeg_ignore_warning => 0 => 0 gettext GetText Support => enabled hash hash support => enabled Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b fnv132 fnv164 joaat haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5 iconv iconv support => enabled iconv implementation => "libiconv" iconv library version => 1.14 Directive => Local Value => Master Value iconv.input_encoding => ISO-8859-1 => ISO-8859-1 iconv.internal_encoding => ISO-8859-1 => ISO-8859-1 iconv.output_encoding => ISO-8859-1 => ISO-8859-1 json json support => enabled json version => 1.2.1 libxml libXML support => active libXML Compiled Version => 2.7.8 libXML Loaded Version => 20708 libXML streams => enabled mbstring Multibyte Support => enabled Multibyte string engine => libmbfl HTTP input encoding translation => disabled libmbfl version => 1.3.2 mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1. Multibyte (japanese) regex support => enabled Multibyte regex (oniguruma) version => 4.7.1 Directive => Local Value => Master Value mbstring.detect_order => no value => no value mbstring.encoding_translation => Off => Off mbstring.func_overload => 0 => 0 mbstring.http_input => pass => pass mbstring.http_output => pass => pass mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml) mbstring.internal_encoding => no value => no value mbstring.language => neutral => neutral mbstring.strict_detection => Off => Off mbstring.substitute_character => no value => no value mcrypt mcrypt support => enabled mcrypt_filter support => enabled Version => 2.5.8 Api No => 20021217 Supported ciphers => cast-128 gost rijndael-128 twofish cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes arcfour Supported modes => cbc cfb ctr ecb ncfb nofb ofb stream Directive => Local Value => Master Value mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value mhash MHASH support => Enabled MHASH API Version => Emulated Support mysql MySQL Support => enabled Active Persistent Links => 0 Active Links => 0 Client API version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $ Directive => Local Value => Master Value mysql.allow_local_infile => On => On mysql.allow_persistent => On => On mysql.connect_timeout => 3 => 3 mysql.default_host => no value => no value mysql.default_password => no value => no value mysql.default_port => 3306 => 3306 mysql.default_socket => MySQL => MySQL mysql.default_user => no value => no value mysql.max_links => Unlimited => Unlimited mysql.max_persistent => Unlimited => Unlimited mysql.trace_mode => Off => Off mysqli MysqlI Support => enabled Client API library version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $ Active Persistent Links => 0 Inactive Persistent Links => 0 Active Links => 0 Directive => Local Value => Master Value mysqli.allow_local_infile => On => On mysqli.allow_persistent => On => On mysqli.default_host => no value => no value mysqli.default_port => 3306 => 3306 mysqli.default_pw => no value => no value mysqli.default_socket => MySQL => MySQL mysqli.default_user => no value => no value mysqli.max_links => Unlimited => Unlimited mysqli.max_persistent => Unlimited => Unlimited mysqli.reconnect => Off => Off mysqlnd mysqlnd => enabled Version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $ Compression => supported SSL => supported Command buffer size => 4096 Read buffer size => 32768 Read timeout => 31536000 Collecting statistics => Yes Collecting memory statistics => No Tracing => n/a Loaded plugins => mysqlnd,example,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password API Extensions => mysql,mysqli,pdo_mysql mysqlnd statistics => bytes_sent => 0 bytes_received => 0 packets_sent => 0 packets_received => 0 protocol_overhead_in => 0 protocol_overhead_out => 0 bytes_received_ok_packet => 0 bytes_received_eof_packet => 0 bytes_received_rset_header_packet => 0 bytes_received_rset_field_meta_packet => 0 bytes_received_rset_row_packet => 0 bytes_received_prepare_response_packet => 0 bytes_received_change_user_packet => 0 packets_sent_command => 0 packets_received_ok => 0 packets_received_eof => 0 packets_received_rset_header => 0 packets_received_rset_field_meta => 0 packets_received_rset_row => 0 packets_received_prepare_response => 0 packets_received_change_user => 0 result_set_queries => 0 non_result_set_queries => 0 no_index_used => 0 bad_index_used => 0 slow_queries => 0 buffered_sets => 0 unbuffered_sets => 0 ps_buffered_sets => 0 ps_unbuffered_sets => 0 flushed_normal_sets => 0 flushed_ps_sets => 0 ps_prepared_never_executed => 0 ps_prepared_once_executed => 0 rows_fetched_from_server_normal => 0 rows_fetched_from_server_ps => 0 rows_buffered_from_client_normal => 0 rows_buffered_from_client_ps => 0 rows_fetched_from_client_normal_buffered => 0 rows_fetched_from_client_normal_unbuffered => 0 rows_fetched_from_client_ps_buffered => 0 rows_fetched_from_client_ps_unbuffered => 0 rows_fetched_from_client_ps_cursor => 0 rows_affected_normal => 0 rows_affected_ps => 0 rows_skipped_normal => 0 rows_skipped_ps => 0 copy_on_write_saved => 0 copy_on_write_performed => 0 command_buffer_too_small => 0 connect_success => 0 connect_failure => 0 connection_reused => 0 reconnect => 0 pconnect_success => 0 active_connections => 0 active_persistent_connections => 0 explicit_close => 0 implicit_close => 0 disconnect_close => 0 in_middle_of_command_close => 0 explicit_free_result => 0 implicit_free_result => 0 explicit_stmt_close => 0 implicit_stmt_close => 0 mem_emalloc_count => 0 mem_emalloc_amount => 0 mem_ecalloc_count => 0 mem_ecalloc_amount => 0 mem_erealloc_count => 0 mem_erealloc_amount => 0 mem_efree_count => 0 mem_efree_amount => 0 mem_malloc_count => 0 mem_malloc_amount => 0 mem_calloc_count => 0 mem_calloc_amount => 0 mem_realloc_count => 0 mem_realloc_amount => 0 mem_free_count => 0 mem_free_amount => 0 mem_estrndup_count => 0 mem_strndup_count => 0 mem_estndup_count => 0 mem_strdup_count => 0 proto_text_fetched_null => 0 proto_text_fetched_bit => 0 proto_text_fetched_tinyint => 0 proto_text_fetched_short => 0 proto_text_fetched_int24 => 0 proto_text_fetched_int => 0 proto_text_fetched_bigint => 0 proto_text_fetched_decimal => 0 proto_text_fetched_float => 0 proto_text_fetched_double => 0 proto_text_fetched_date => 0 proto_text_fetched_year => 0 proto_text_fetched_time => 0 proto_text_fetched_datetime => 0 proto_text_fetched_timestamp => 0 proto_text_fetched_string => 0 proto_text_fetched_blob => 0 proto_text_fetched_enum => 0 proto_text_fetched_set => 0 proto_text_fetched_geometry => 0 proto_text_fetched_other => 0 proto_binary_fetched_null => 0 proto_binary_fetched_bit => 0 proto_binary_fetched_tinyint => 0 proto_binary_fetched_short => 0 proto_binary_fetched_int24 => 0 proto_binary_fetched_int => 0 proto_binary_fetched_bigint => 0 proto_binary_fetched_decimal => 0 proto_binary_fetched_float => 0 proto_binary_fetched_double => 0 proto_binary_fetched_date => 0 proto_binary_fetched_year => 0 proto_binary_fetched_time => 0 proto_binary_fetched_datetime => 0 proto_binary_fetched_timestamp => 0 proto_binary_fetched_string => 0 proto_binary_fetched_blob => 0 proto_binary_fetched_enum => 0 proto_binary_fetched_set => 0 proto_binary_fetched_geometry => 0 proto_binary_fetched_other => 0 init_command_executed_count => 0 init_command_failed_count => 0 com_quit => 0 com_init_db => 0 com_query => 0 com_field_list => 0 com_create_db => 0 com_drop_db => 0 com_refresh => 0 com_shutdown => 0 com_statistics => 0 com_process_info => 0 com_connect => 0 com_process_kill => 0 com_debug => 0 com_ping => 0 com_time => 0 com_delayed_insert => 0 com_change_user => 0 com_binlog_dump => 0 com_table_dump => 0 com_connect_out => 0 com_register_slave => 0 com_stmt_prepare => 0 com_stmt_execute => 0 com_stmt_send_long_data => 0 com_stmt_close => 0 com_stmt_reset => 0 com_stmt_set_option => 0 com_stmt_fetch => 0 com_deamon => 0 bytes_received_real_data_normal => 0 bytes_received_real_data_ps => 0 example statistics => stat1 => 0 stat2 => 0 odbc ODBC Support => enabled Active Persistent Links => 0 Active Links => 0 ODBC library => Win32 Directive => Local Value => Master Value odbc.allow_persistent => On => On odbc.check_persistent => On => On odbc.default_cursortype => Static cursor => Static cursor odbc.default_db => no value => no value odbc.default_pw => no value => no value odbc.default_user => no value => no value odbc.defaultbinmode => return as is => return as is odbc.defaultlrl => return up to 4096 bytes => return up to 4096 bytes odbc.max_links => Unlimited => Unlimited odbc.max_persistent => Unlimited => Unlimited pcre PCRE (Perl Compatible Regular Expressions) Support => enabled PCRE Library Version => 8.32 2012-11-30 Directive => Local Value => Master Value pcre.backtrack_limit => 1000000 => 1000000 pcre.recursion_limit => 100000 => 100000 PDO PDO support => enabled PDO drivers => mysql, sqlite pdo_mysql PDO Driver for MySQL => enabled Client API version => mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $ pdo_sqlite PDO Driver for SQLite 3.x => enabled SQLite Library => 3.7.7.1 Phar Phar: PHP Archive support => enabled Phar EXT version => 2.0.1 Phar API version => 1.1.1 SVN revision => $Id: c5042cc34acebcc0926625b57dff03deebbe6472 $ Phar-based phar archives => enabled Tar-based phar archives => enabled ZIP-based phar archives => enabled gzip compression => enabled bzip2 compression => enabled OpenSSL support => disabled (install ext/openssl) Phar based on pear/PHP_Archive, original concept by Davey Shafik. Phar fully realized by Gregory Beaver and Marcus Boerger. Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle. Directive => Local Value => Master Value phar.cache_list => no value => no value phar.readonly => On => On phar.require_hash => On => On Reflection Reflection => enabled Version => $Id: 6c4d8062369898a397e4b128348042f5c01b4427 $ session Session Support => enabled Registered save handlers => files user Registered serializer handlers => php php_binary wddx Directive => Local Value => Master Value session.auto_start => Off => Off session.cache_expire => 180 => 180 session.cache_limiter => nocache => nocache session.cookie_domain => no value => no value session.cookie_httponly => Off => Off session.cookie_lifetime => 0 => 0 session.cookie_path => / => / session.cookie_secure => Off => Off session.entropy_file => no value => no value session.entropy_length => 0 => 0 session.gc_divisor => 1000 => 1000 session.gc_maxlifetime => 1440 => 1440 session.gc_probability => 1 => 1 session.hash_bits_per_character => 5 => 5 session.hash_function => 0 => 0 session.name => PHPSESSID => PHPSESSID session.referer_check => no value => no value session.save_handler => files => files session.save_path => \xampp\tmp => \xampp\tmp session.serialize_handler => php => php session.upload_progress.cleanup => On => On session.upload_progress.enabled => On => On session.upload_progress.freq => 1% => 1% session.upload_progress.min_freq => 1 => 1 session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.prefix => upload_progress_ => upload_progress_ session.use_cookies => On => On session.use_only_cookies => Off => Off session.use_trans_sid => 0 => 0 SimpleXML Simplexml support => enabled Revision => $Id: 692516840b2d7d6e7aedb0bedded1f53b764a99f $ Schema support => enabled soap Soap Client => enabled Soap Server => enabled Directive => Local Value => Master Value soap.wsdl_cache => 1 => 1 soap.wsdl_cache_dir => /tmp => /tmp soap.wsdl_cache_enabled => 1 => 1 soap.wsdl_cache_limit => 5 => 5 soap.wsdl_cache_ttl => 86400 => 86400 sockets Sockets Support => enabled SPL SPL support => enabled Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException sqlite3 SQLite3 support => enabled SQLite3 module version => 0.7 SQLite Library => 3.7.7.1 Directive => Local Value => Master Value sqlite3.extension_dir => no value => no value standard Dynamic Library Support => enabled Path to sendmail => \xampp\mailtodisk\mailtodisk.exe Directive => Local Value => Master Value assert.active => 1 => 1 assert.bail => 0 => 0 assert.callback => no value => no value assert.quiet_eval => 0 => 0 assert.warning => 1 => 1 auto_detect_line_endings => 0 => 0 default_socket_timeout => 60 => 60 from => no value => no value url_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame=src,input=src,form=fakeentry user_agent => no value => no value tokenizer Tokenizer Support => enabled wddx WDDX Support => enabled WDDX Session Serializer => enabled xml XML Support => active XML Namespace Support => active libxml2 Version => 2.7.8 xmlreader XMLReader => enabled xmlrpc core library version => xmlrpc-epi v. 0.51 php extension version => 0.51 author => Dan Libby homepage => http://xmlrpc-epi.sourceforge.net open sourced by => Epinions.com xmlwriter XMLWriter => enabled xsl XSL => enabled libxslt Version => 1.1.27 libxslt compiled against libxml Version => 2.7.8 EXSLT => enabled libexslt Version => 0.8.16 zip Zip => enabled Extension Version => $Id: 0c033d4e4613d577409950ed7bf8da4b68286d15 $ Zip version => 1.11.0 Libzip version => 0.10.1 zlib ZLib Support => enabled Stream Wrapper => compress.zlib:// Stream Filter => zlib.inflate, zlib.deflate Compiled Version => 1.2.7 Linked Version => 1.2.7 Directive => Local Value => Master Value zlib.output_compression => Off => Off zlib.output_compression_level => -1 => -1 zlib.output_handler => no value => no value Additional Modules Module Name Environment Variable => Value ALLUSERSPROFILE => C:\ProgramData APPDATA => C:\Users\G?bor\AppData\Roaming COMMANDER_DRIVE => C: COMMANDER_EXE => C:\totalcmd\TOTALCMD64.EXE COMMANDER_INI => C:\Users\G?bor\AppData\Roaming\GHISLER\wincmd.ini COMMANDER_PATH => C:\totalcmd CommonProgramFiles => C:\Program Files (x86)\Common Files CommonProgramFiles(x86) => C:\Program Files (x86)\Common Files CommonProgramW6432 => C:\Program Files\Common Files COMPUTERNAME => GABOR-PC ComSpec => C:\Windows\system32\cmd.exe FP_NO_HOST_CHECK => NO HOMEDRIVE => C: HOMEPATH => \Users\G?bor LOCALAPPDATA => C:\Users\G?bor\AppData\Local LOGONSERVER => \\GABOR-PC NB_EXEC_EXTEXECUTION_PROCESS_UUID => 49c095e0-22fb-406c-ae79-18348f524fac NUMBER_OF_PROCESSORS => 2 OS => Windows_NT Path => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;e:\Program Files (x86)\AOMEI Backupper Professional Edition 2.0;C:\Program Files\jEdit PATHEXT => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE => x86 PROCESSOR_ARCHITEW6432 => AMD64 PROCESSOR_IDENTIFIER => AMD64 Family 15 Model 107 Stepping 2, AuthenticAMD PROCESSOR_LEVEL => 15 PROCESSOR_REVISION => 6b02 ProgramData => C:\ProgramData ProgramFiles => C:\Program Files (x86) ProgramFiles(x86) => C:\Program Files (x86) ProgramW6432 => C:\Program Files PSModulePath => C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC => C:\Users\Public SESSIONNAME => Console SystemDrive => C: SystemRoot => C:\Windows TEMP => C:\Users\GBOR~1\AppData\Local\Temp TMP => C:\Users\GBOR~1\AppData\Local\Temp USERDOMAIN => Gabor-PC USERNAME => G?bor USERPROFILE => C:\Users\G?bor windir => C:\Windows windows_tracing_flags => 3 windows_tracing_logfile => C:\BVTBin\Tests\installpackage\csilogfile.log PHP Variables Variable => Value _SERVER["ALLUSERSPROFILE"] => C:\ProgramData _SERVER["APPDATA"] => C:\Users\G?bor\AppData\Roaming _SERVER["COMMANDER_DRIVE"] => C: _SERVER["COMMANDER_EXE"] => C:\totalcmd\TOTALCMD64.EXE _SERVER["COMMANDER_INI"] => C:\Users\G?bor\AppData\Roaming\GHISLER\wincmd.ini _SERVER["COMMANDER_PATH"] => C:\totalcmd _SERVER["CommonProgramFiles"] => C:\Program Files (x86)\Common Files _SERVER["CommonProgramFiles(x86)"] => C:\Program Files (x86)\Common Files _SERVER["CommonProgramW6432"] => C:\Program Files\Common Files _SERVER["COMPUTERNAME"] => GABOR-PC _SERVER["ComSpec"] => C:\Windows\system32\cmd.exe _SERVER["FP_NO_HOST_CHECK"] => NO _SERVER["HOMEDRIVE"] => C: _SERVER["HOMEPATH"] => \Users\G?bor _SERVER["LOCALAPPDATA"] => C:\Users\G?bor\AppData\Local _SERVER["LOGONSERVER"] => \\GABOR-PC _SERVER["NB_EXEC_EXTEXECUTION_PROCESS_UUID"] => 49c095e0-22fb-406c-ae79-18348f524fac _SERVER["NUMBER_OF_PROCESSORS"] => 2 _SERVER["OS"] => Windows_NT _SERVER["Path"] => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;e:\Program Files (x86)\AOMEI Backupper Professional Edition 2.0;C:\Program Files\jEdit _SERVER["PATHEXT"] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC _SERVER["PROCESSOR_ARCHITECTURE"] => x86 _SERVER["PROCESSOR_ARCHITEW6432"] => AMD64 _SERVER["PROCESSOR_IDENTIFIER"] => AMD64 Family 15 Model 107 Stepping 2, AuthenticAMD _SERVER["PROCESSOR_LEVEL"] => 15 _SERVER["PROCESSOR_REVISION"] => 6b02 _SERVER["ProgramData"] => C:\ProgramData _SERVER["ProgramFiles"] => C:\Program Files (x86) _SERVER["ProgramFiles(x86)"] => C:\Program Files (x86) _SERVER["ProgramW6432"] => C:\Program Files _SERVER["PSModulePath"] => C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ _SERVER["PUBLIC"] => C:\Users\Public _SERVER["SESSIONNAME"] => Console _SERVER["SystemDrive"] => C: _SERVER["SystemRoot"] => C:\Windows _SERVER["TEMP"] => C:\Users\GBOR~1\AppData\Local\Temp _SERVER["TMP"] => C:\Users\GBOR~1\AppData\Local\Temp _SERVER["USERDOMAIN"] => Gabor-PC _SERVER["USERNAME"] => G?bor _SERVER["USERPROFILE"] => C:\Users\G?bor _SERVER["windir"] => C:\Windows _SERVER["windows_tracing_flags"] => 3 _SERVER["windows_tracing_logfile"] => C:\BVTBin\Tests\installpackage\csilogfile.log _SERVER["PHP_SELF"] => E:\STY PHP in 24 Hours\Hour 03\listing3.1.php _SERVER["SCRIPT_NAME"] => E:\STY PHP in 24 Hours\Hour 03\listing3.1.php _SERVER["SCRIPT_FILENAME"] => E:\STY PHP in 24 Hours\Hour 03\listing3.1.php _SERVER["PATH_TRANSLATED"] => E:\STY PHP in 24 Hours\Hour 03\listing3.1.php _SERVER["DOCUMENT_ROOT"] => _SERVER["REQUEST_TIME_FLOAT"] => 1410352537.6357 _SERVER["REQUEST_TIME"] => 1410352537 _SERVER["argv"] => Array ( [0] => E:\STY PHP in 24 Hours\Hour 03\listing3.1.php ) _SERVER["argc"] => 1 PHP License This program is free software; you can redistribute it and/or modify it under the terms of the PHP License as published by the PHP Group and included in the distribution in the file: LICENSE This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact license@php.net.