• " . $txt1 . "
  • Php form Demo




    Download 199,73 Kb.
    Sana16.05.2024
    Hajmi199,73 Kb.
    #237685

    9-Amaliy ish.
    PHPda satrlar, massivlar, fayllar va formalar bilan ishlash.

    Pasda PHP da berilgan kodlarni ishlashi uchun open server yoki xampp yoki boshqa server dasturlaridan birini o`rnatish shart bo`ladi aks holda kodni ishlatish imkoni bo`lmaydi. Xar bir misol istalgan redaktorda yozilgandan so`ng uni birnarsa.php deb tegish joyga saqlash kerak.



    Menda C diskda open server ichida domain papka ichida yuqorida ko`rsatilgan papkalar ichida joylashgan. Misolni saqlagandan keyin serverni ishga tushurish lozim bo`ladi.

    Open serverni ishga tushurib zapustit qilish kerak. Zapustit qilish kompyuterning o`ng tomoni soat oldida chiqadi

    Menda zapustit qilish aktiv turibdi agar kodlarimda biror o`zgarish bo`lsa perezapustit qilishni o`zi kifoya. Endi menda formaga tegishli bo`lgan misolni ishga tushirib ko`rsataman. Kerakli misollarni brauzer orqali ko`rish uchun yuqoridagi moy proekt bo`limidan tanlab yoki shunchaki papka qanday nomlangan bo`lsa brauzer qidiruv oynasiga papka nomini yozishni o`zi kifoya. Demak brauzer orqali ochishni ko`rib chiqamiz.

    Yuqoridagi rasmga e`tibor qilsangiz men shunchaki form.uz yozish orqali kerakli misolni ishga tushurdim.







    echo "My first PHP script!";
    ?>

    $txt = "PHP";
    echo "I love $txt!";
    ?>

    // This is a single-line comment
    # This is also a single-line comment
    ?>

    // You can also use comments to leave out parts of a code line
    $x = 5 /* + 15 */ + 5;
    echo $x;
    ?>

    $txt = "Hello world!";
    $x = 5;
    $y = 10.5;
    echo $txt;
    echo "
    ";
    echo $x;
    echo "
    ";
    echo $y;
    ?>

    $x = 5; // global scope
    function myTest() {
    // using x inside this function will generate an error
    echo "
    Variable x inside function is: $x
    ";
    }
    myTest();
    echo "
    Variable x outside function is: $x
    ";
    ?>

    function myTest() {
    $x = 5; // local scope
    echo "
    Variable x inside function is: $x
    ";
    }
    myTest();

    // using x outside the function will generate an error


    echo "
    Variable x outside function is: $x
    ";
    ?>

    $txt1 = "Learn PHP";
    $txt2 = "W3Schools.com";
    $x = 5;
    $y = 4;
    echo "

    " . $txt1 . "

    ";
    echo "Study PHP at " . $txt2 . "
    ";
    echo $x + $y;
    ?>

    $cars = array("Volvo", "BMW", "Toyota");
    echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
    ?>

















    Download 199,73 Kb.




    Download 199,73 Kb.