Jump to content

[SOLVED] Need help figuring out this php include.


bgbs

Recommended Posts

I wan to have the ability to change certain data on the  site from one file; to modify items and not have to go into each page that reflects that description or title.

 

So I created a php file naming it data.php

In data.php I put this

$phone = "1.877.894.8555";
$email = "info [at] mobirecycle.com";

 

Then I included data.php file into my global header like this:

<?php include("data.php");?> 

 

Then in the php file I put the echo statement like this:

  <p><span class="bold">Mobirecycle can be contacted at:</span> <?php echo "$phone"; ?></p>

 

 

What it does is just spit everything that is in the data.php file, including all the code, on the header, and nothing appears in the echo statement.

 

What have I done wrong?

 

You still need to wrap your PHP inside included files with appropriate php tags.

 

<?php
$phone = "1.877.894.8555";
$email = "info [at] mobirecycle.com";
?>

 

Otherwise it'll be read like any other file, not parsed by PHP, so those variables are never stored.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.