Home > Software design >  PHP code snippets not executing in browser
PHP code snippets not executing in browser

Time:01-20

I have correctly installed PHP on my computer and XAMPP is working properly. But when I load the file in my browser, only the HTML is responding. It seems to not load the PHP snippets. Can anybody help me with this? I'm stuck :(

screenshot

I've tried changing the file paths to find the snippets folder and the files in them. I've also tried reinstalling PHP in my computer.

CodePudding user response:

The code isn't executing because you didn't specify an output statement

Replace with

<?php echo $_SERVER["DOCUMENT_ROOT"]...

OR

<?=$_SERVER["DOCUMENT_ROOT"]...

CodePudding user response:

SOLUTION Thanks for everyone's input! I really appreciate it! The thing that I tried that worked is adding required in the code.

FROM

<?php $_SERVER['DOCUMENT_ROOT'].'/phpmotors/snippets/header.php'; ?>

TO

<?php require $_SERVER['DOCUMENT_ROOT'].'/phpmotors/snippets/header.php'; ?>

  • Related