Tommy
Tommy

Reputation: 75

PHP giving blank page with the following code with errors turned on

I know this question keeps getting asked, but as far as i can see its just a syntax error and I cant see it. The code is as follows

on index.php:

    <?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE); ?>

<? require($_SERVER["DOCUMENT_ROOT"] . '/WestAncroftSettings.php' ); ?>


<?php include("$ACCESS_PATH" . "/WestAncroft2/Pages/Main/Main.php");?>

and on WestAncroftSettings.php:

<?php $ACCESS_PATH = 'http://' . $_SERVER['HTTP_HOST'].'/WestAncroft2'; ?>

<?php $IMAGE_PATH = 'http://' . $_SERVER['HTTP_HOST'].'/WestAncroft2/images'; ?>

and on Main.php:

<? require($_SERVER[DOCUMENT_ROOT] . '/WestAncroftSettings.php' ); ?>

If you want the rest of the content on the pages just ask.

Upvotes: 0

Views: 169

Answers (3)

Harsha
Harsha

Reputation: 816

You can use short form (<? ?>) of PHP's open tag by enabling the "short_open_tag" to 1 in php.ini file. After change, keep in mind to restart the Apache server.

Then you can use (<? ?>) and (<?php ?>) both in your project.

But bear in mind that If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?>.

Upvotes: 0

Random Programmer
Random Programmer

Reputation: 51

It is a typo indeed

<? require($_SERVER["DOCUMENT_ROOT"] . '/WestAncroftSettings.php' ); ?>

should be

<?php require($_SERVER["DOCUMENT_ROOT"] . '/WestAncroftSettings.php' ); ?>

and later in your code you have the same line again without <?php and your missing quotes around DOCUMENT_ROOT

Upvotes: 0

user466764
user466764

Reputation: 1176

The second example of this line has missing quotes and agree with Prisoner - check short tag settings. It's advisable to use long tag names in case you change servers at some point in the future

<?php require($_SERVER["DOCUMENT_ROOT"] . '/WestAncroftSettings.php' ); ?>

Upvotes: 1

Related Questions