Çözüldü PHP kodundaki hata nedir?

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

hayl0s

Decapat
Katılım
17 Eylül 2021
Mesajlar
398
Çözümler
2
Daha fazla  
Cinsiyet
Erkek
Merhaba, kod şu şekilde:
PHP:
<!DOCTYPE html>
<html>
<head>
    <title>Get, Post İşlemleri</title>
</head>
<body>
    <?php
        if(!$_GET);
        {
            ?>
            <form method="get" action="get.php">
                Sayı girin: <input type="number" name="sayi">
                <button type="submit">Tıkla</button>
            </form>
        <?php
        }

        else{

            function hesaplama()
            {
                $x=$_GET['sayi'];
                echo"Girilen sayı:    ".$x;
            }
            hesaplama();
        }
        ?>
</body>
</html>
Hata şu şekilde:
1680116394407.png

Ne yapmam gerekiyor? Neyi yanlış yaptım?
 

Dosya Ekleri

  • 1680116381215.png
    1680116381215.png
    17 KB · Görüntüleme: 30
Son düzenleyen: Moderatör:
Çözüm
İf bloğu sonu ; ile bitmez PHP'de.

PHP:
<?php
        if(!$_GET)
        {
            ?>
            <form method="get" action="get.php">
                Sayı girin: <input type="number" name="sayi">
                <button type="submit">Tıkla</button>
            </form>
        <?php
        }

        else{

            function hesaplama()
            {
                $x=$_GET['sayi'];
                echo"Girilen sayı:    ".$x;
            }
            hesaplama();
        }
        ?>
İf bloğu sonu ; ile bitmez PHP'de.

PHP:
<?php
        if(!$_GET)
        {
            ?>
            <form method="get" action="get.php">
                Sayı girin: <input type="number" name="sayi">
                <button type="submit">Tıkla</button>
            </form>
        <?php
        }

        else{

            function hesaplama()
            {
                $x=$_GET['sayi'];
                echo"Girilen sayı:    ".$x;
            }
            hesaplama();
        }
        ?>
 
Çözüm
İf bloğu sonu ; ile bitmez PHP'de.

PHP:
<?php
        if(!$_GET)
        {
            ?>
            <form method="get" action="get.php">
                Sayı girin: <input type="number" name="sayi">
                <button type="submit">Tıkla</button>
            </form>
        <?php
        }

        else{

            function hesaplama()
            {
                $x=$_GET['sayi'];
                echo"Girilen sayı:    ".$x;
            }
            hesaplama();
        }
        ?>
Teşekkür ederim <3
 
Bu hatanın sebebi zaten hatada belli oluyor. Sözdiziminde hata var hocam.

Kod:
<!DOCTYPE html>
<html>
<head>
    <title>Get, Post İşlemleri</title>
</head>
<body>
    <?php
        if(empty($_GET)) {
    ?>
            <form method="get" action="get.php">
                Sayı girin: <input type="number" name="sayi">
                <button type="submit">Tıkla</button>
            </form>
    <?php
        } else {
            function hesaplama() {
                $x=$_GET['sayi'];
                echo "Girilen sayı:    ".$x;
            }
            hesaplama();
        }
    ?>
</body>
</html>


ChatGPT, kullanmak yasak hocam.
 

Yeni konular

Geri
Yukarı