ranyeli
10/16/2017 - 3:30 AM

Sample index.php file

Sample php file mixing html and php code


<html>
    <head>
        <title><?php echo "it works!"; ?></title>
    </head>
    <body>
        <?php
        spl_autoload_register(function ($class_name) {
            include $class_name . '.php';
        });
            echo "<h1>So it seems</h1>";
            $etc = "here I am";
            $ar = array("hola", "bye", "hi", "adios");
        ?>
        <h2><?php echo __DIR__;?></h2>
        <p>
        <?php echo isset($etc) ? $etc : "it is not set"; ?>
        </p>
        <h3><?php
            // require __DIR__.'/myclass.php';
            $clazz = new MyClass("huevo", "jamon");
            // echo $clazz->getThem();
            echo MyClass::getIt(), " ... ", $clazz->getThem();
        ?></h3>

        <strong><h4><?php echo $_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"], " - ", var_dump($etc); ?></h4></strong>

        <?php foreach($ar as $key => $a):  ?>
            <em>a = <?php echo $a; ?> and key = <?php echo $key; ?></em>
        <?php endforeach; ?>
    </body>
</html>