Php includes display code

PROBLEM: When I include the php file at the top of my page, instead of running the script, it shows the code.

If I do a simple echo command on the page, it works fine, but that includes no file.

I am having problems with this question and I cannot find a solution that solves the problem. Most of the similar problems I've seen are solved with longhand php tags instead of shorthand.

Code

index.php is located in the root folder init.php is located in a folder named "core" which is located in the root folder.

Included file: init.php

<?php
session_start();

$GLOABALS['config'] = array (
    'mysql' => array (
        'host'      => '127.0.0.1',
        'username'  => 'root',
        'password'  => '',
        'db'        => 'lr'
    ),
    'remember' => array (
        'cookie_name'       => 'hash',
        'cookie_expiry'     => 604800
    ),
    'session' => array (
        'session_name'      => 'user'
    )
);

spl_autoload_register (function ($class){
    require_once 'classes/' . $class . '.php';
});

require_once 'functions/sanitize.php';
?>

      

Including page: index.php

<?php include '/core/init.php'?>

<!-- Web Page Stuff -->

      

sanatize.php

function escape ($string){
return htmlentities ($string, ENT_QUOTES, "UTF-8");
}

      

Why is php showing up and not starting?

+3


source to share


2 answers


Check your sanitize.php file. I think there is probably a bug in there.



0


source


you are missing

<?php
?>

      

in your file.



But wow !! So I have to understand that any include error during PHP development will bypass the entire library file in the web browser? !!?! So foreign to my concept of full stack programming or cybersecurity where it all ends up in a private error log, never exposing the code to the client.

NO WAY - PHP, NOR APPARENTLY WIL PHP, EVER WILL BE MORE SAFE THAN A PERL IN MY OPINION !!! This way, Perl has more server-side capabilities, you don't miss out on "free" code that doesn't really even require variable definitions. Does it give an internal structure code on any error or only when parsing errors for instances ?!

-1


source







All Articles