0

I have an include in the head of my php file:

include 'scripts/tracking_code.php';

In there, I run a basic test with if/else and echo some basic text.

Problem is that nothing is getting printed to screen.

I then just tried to print something a little more basic... The tracking_code.php now simply includes this:

echo "<!-- This is the file -->";

Still nothing?

I know the include is getting included because when I turn E_ALL error reporting, the $_GET[] call throws a "Notice: Undefined index:"

Here is my original code (before simply replacing with "echo" (as above))

<?php

$trackingid = $_GET['trackingid'];

if ( !empty( $trackingid ) ) {
    echo "<!-- trackingid: $trackingid -->";
} else { 
    echo "<!-- trackingid is empty -->";
}
?>

Yet nothing is ever printed?

What am I missing?

6
  • 1
    Are you sure you're looking at the source and not the HTML output (which would render HTML comments invisible)? Commented Jul 22, 2013 at 1:30
  • Definitely looking at the source ... I am printing before any HTML and there is nothing appearing Commented Jul 22, 2013 at 1:38
  • 1
    <!-- trackingid: $trackingid --> signifies a comment in HTML and you'll not see it on the screen. Commented Jul 22, 2013 at 1:39
  • Yes: Right click -> View Source - It is a comment because I don't want it printing on screen for consumers to see Commented Jul 22, 2013 at 1:43
  • It would appear that comments do not print in the source before the <DOCTYPE> tag... Would this be correct? Commented Jul 22, 2013 at 1:59

1 Answer 1

3

Is your tracking script echo "<!-- This is the file -->"; or is it

<?php
  echo "<!-- This is the file -->";
?>

Because without the php tags, there's a good chance that your require call actually makes PHP go "this is not actually a PHP file and as such I cannot require it" but with the error/warning repressed due to whatever error reporting settings are active when you run the code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.