saiko Posted March 15, 2006 Share Posted March 15, 2006 EDIT: topic title supose to say " use variables in html WITHOUT php brackets"how can i use variables in html without having to do the php brackets: <?php $variable; ?> ?? Quote Link to comment Share on other sites More sharing options...
greycap Posted March 15, 2006 Share Posted March 15, 2006 A couple of ways that you can use.[b]1) Put your html in print statements:[/b][code] print "<htm>" . "<head><title> $pageTitle </title></head>" . "<body>"; /* etc */[/code][b]2) Use place holders and then parse your text.[/b][code]$html = <<< HTML<h2>[TITLE]<h2>Posted [DATE] by [AUTHOR]HTML;$search = array($postTitle, $postDate, $postAuthor);$repace = array('[TITLE]', '[DATE]', '[AUTHOR]');$html = str_replace($search,$replace,$html);print $html;[/code]The good thing about the second method is that you can read that from a file. I typically have html files with variable place holders for different sections of the page (header, footer, navbar, etc). The best thing about this method is that you are separating your content from your code. If you do it properly, you can adjust one without messing up the other. Also works well when you start working with someone who has little or no programming knowledge. Quote Link to comment Share on other sites More sharing options...
keeB Posted March 15, 2006 Share Posted March 15, 2006 You can't...PHP is a scripting language, not a mind reader..What if you wanted to make a HTML page.. that said IF MY GRANDMA GOT CAUGHT IN A STORM, I WOULDNT KNOW WHAT TO DO..See how in that sentene alone, you have a few reserved words.. imagine PHP trying to process all of that and determined if it was supposed to be code or not. That'd be one slow page, wouldn't it?SO. You're stuck with the <?, <%, or however else you call it. Quote Link to comment Share on other sites More sharing options...
saiko Posted March 15, 2006 Author Share Posted March 15, 2006 your sorta on the rite track.this is also part of my skining system.it gets the file site_head.php now i dont want the admin having to put <?php echo $variable;?> on everthing so i was thinking i could use some other way.things i want are things such as the "images path" is stored in the variable "$images_path" so if it was set to "skins/1/images" then i want to add that to the start of all there images linkseg. they have "images_01.jpg" i want it to be changed to "skins/1/images/images/images_01.jpg"so wat im trying to say is there a way i can find and replace the code in the file.or is there a way i can use another method of echoing the variables other then using the <?php echo $variable; ?>like with ipb how they do <% TITLE %> ---- NOTE: i dont have a clue how to do this ------hope you can understand :D Quote Link to comment Share on other sites More sharing options...
saiko Posted March 15, 2006 Author Share Posted March 15, 2006 *bump* Quote Link to comment 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.