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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.