Home>

There is an index.php file that accepts all requests and each request processes the colous.

Require 'Flight /Flight.php';
Flight :: ROUTE ('GET /', FUNCTION () {
    Flight :: Render ('Home', Array ('body_class'= >
 'Frontpage'));
});
Flight :: Route ('GET /images', Function () {
    $ SQL= "SELECT * from images";
    try {
        $ db= getConnection ();
        $ STMT= $ DB->
Prepare ($ SQL);
        $ STMT->
Execute ();
        $ STMT->
SetFetchmode (PDO :: Fetch_assoc);
        $ result= json_encode ($ STMT->
fetchall ());
        $ db= null;
        Echo $ Result;
    } Catch (PDOException $ E) {
        Echo $ E->
getMessage ();
    }
});
Flight :: start ();
FUNCTION GETCONNECTION ()
{
    $ dbhost= "127.0.0.1";
    $ dbuser= "root";
    $ dbpass= "";
    $ dbname= "test";
    $ dbh= new pdo ("mysql: host= $ dbhost; dbname= $ dbname", $ dbuser, $ dbpass);
    $ dbh->
SetAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_WARNING);
    Return $ dbh;
}

Can I ask my heder in each of the columns? For example, in the second rut I need JSON, and in the first HTML.

  • Answer # 1

    by experiment found out that you can write several heders in one file. In this case, in the second column, I can install Hader on the Application /JSON, in all other cases there will be just text /html by default.

    What you wrote the code does not mean that it will be executed. All that lies inside the unprizable functions and blocks of the code, whose conditions were not satisfied, will not be fulfilled, and, as far as I understand, it will not be able to influence the progress of the program in any way.

    etki2021-05-20 01:12:45