Jump to content

PHP and HTML within echo?


master82

Recommended Posts

I have a list of links on the left of my page which is a combination of HTML and PHP coding. However, everytime I come to create a new page I have to go back to all my other page(s) and add the new link on...

So is it possible to copy the link data and put it into a variable (eg $links) and then echo this on my pages to save me time (also this would mean I only have to update the code once rather than on each page).

I could simply then have include and echo the $link - but can you echo HTML and PHP?

I tried but it never worked, anyone know of a way?
Link to comment
Share on other sites

You can create file and called it links.html which will store all your links then where ever you want you links to display you use this code:
[code]<?php include 'links.html'; ?>[/code]
And your links will appear where ever you place the include.

Therefore you can just edit the links.html file to edit your links or to add in links and it'll be reflected instantly throughout your site.
Link to comment
Share on other sites

No its nothing to do with frames! You dont need to echo anything either with echo! ie:
[b]links.html[/b]
[code]<a href="index.php">Home</a><br />
<a href="tutorials.php">Tutorials</a><br />
<a href="porfolio.pgp">Portfolio</a><br />
.. more links here ..[/code]
Now in your page you do this:
[code]<?php

//some code here

include 'links.html';

?>[/code]
Now when PHP goes to parse your code it'll basically get the contents of links.html and copy 'n' paste it where include was stated

No need for frames or anythink! Just try it out.
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.