lundi 6 juin 2016

Shorthand If / Else require_once PHP

So Here's My Code. It Works When I Use Longer If Statement, But Not When I Use Shorthand. Sorry For My Bad English.

<?php 

function __autoload($class) {

    $path = "includes/{$class}.php";

    // IT WORKS LIKE THIS

     if (file_exists($path)) {

        require_once($path);

     }

     else {

        die("File Not Found :(");

     }

    //But Not Like This

    require_once() file_exists($path) ? $path : die("File Not Found :(");

}

?>

Aucun commentaire:

Enregistrer un commentaire