master82 Posted June 15, 2006 Share Posted June 15, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/12056-php-and-html-within-echo/ Share on other sites More sharing options...
wildteen88 Posted June 15, 2006 Share Posted June 15, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12056-php-and-html-within-echo/#findComment-45839 Share on other sites More sharing options...
master82 Posted June 15, 2006 Author Share Posted June 15, 2006 Will this way mean I will have to use frames? or will it just be echo ing as normal?I'm trying to avoid using frames if possible Quote Link to comment https://forums.phpfreaks.com/topic/12056-php-and-html-within-echo/#findComment-45854 Share on other sites More sharing options...
wildteen88 Posted June 15, 2006 Share Posted June 15, 2006 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 hereinclude '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 statedNo need for frames or anythink! Just try it out. Quote Link to comment https://forums.phpfreaks.com/topic/12056-php-and-html-within-echo/#findComment-45860 Share on other sites More sharing options...
master82 Posted June 15, 2006 Author Share Posted June 15, 2006 Your a star! Quote Link to comment https://forums.phpfreaks.com/topic/12056-php-and-html-within-echo/#findComment-45861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.