anya7 Posted January 25, 2007 Share Posted January 25, 2007 I’m working with a site that’s all (mostly) plain html done in Dreamweaver templates. The site’s over 1000 pages and it’s had maybe a dozen different people updating it over the years which has lots of mis-matched, inconsistently done pages and a few entire sections that weren’t even done with the template. I’ve been given the task of “fixing” it, so to speak. The current system is obviously pretty inefficient so I was considering the possibility of switching it over to a php-based template system, which would look roughly something like this:[code]<? $title = “blah”;include(“header.php”); ?>html stuff blah blah<? echo $title; ?>more html stuff blah blah<? include(“footer.php”); ?>[/code]The problem is that this would require whoever’s making the pages to escape all the quotes and semicolons and such that would be in the title (and they definitely will be there). The regular web person always knows some html (enough to update the pages, anyway), but not necessarily php and sometimes the pages are updated by other people, who don’t really know html but can manage to find their way through Dreamweaver with detailed instructions. I don’t want to have to explain to them that they have to escape certain characters, and then trust them to remember to actually do it. Is there any other way to accomplish getting stuff stored in a variable without having to escape anything? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 25, 2007 Share Posted January 25, 2007 they don't have to escape them, you could do print htmlentities($title) instead of just printing it. Quote Link to comment Share on other sites More sharing options...
anya7 Posted January 25, 2007 Author Share Posted January 25, 2007 Uhh...could you explain how to do that in more detail? My knowledge of php is fairly limited and I work best with specific examples. ;) Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 25, 2007 Share Posted January 25, 2007 <? echo htmlentities($title); ?> Quote Link to comment Share on other sites More sharing options...
anya7 Posted January 26, 2007 Author Share Posted January 26, 2007 Uhh...that still doesn't solve the problem that you can't do stuff like $title="a title with a "quote" in it" without getting lovely error messages. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 26, 2007 Share Posted January 26, 2007 You can do[code]<?php$title = 'a title with a "quote" in it';$title1 = "a title with a \"quote\" in it";$double_quote = htmlentities('"',ENT_QUOTES);$single_quote = htmlentitie("'",ENT_QUOTEs);$title2 = "a title with a " . $double_quote . "quote" . $double_quote . " in it";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 26, 2007 Share Posted January 26, 2007 You could put comments right about it that EXPLAIN what to do. That's what comments are for.// Hey, coworkers!!! Yes, YOU! Don't put any quotes in without a \ in front! OR ELSE! 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.