eldan88 Posted April 28, 2013 Share Posted April 28, 2013 Hey, I have a from on a custom web application that sets up constants. The issue that I am running into is that, I am trying to Define a constant called "Google analytics" However when I enter the google analytics in the text area, there are double quotes within double quotes, when it defines the constant How do a escape that using my form? Below is the code I am using for the form ....... This is the text area where I enter my constants <textarea style="width:153px; height:70px" name="GOOGLE_ANALYTICS"><?=defined("GOOGLE_ANALYTICS")?GOOGLE_ANALYTICS:"";?></textarea> This is the code that process's the constant $config_file_contents="<?php \n"; foreach($_POST as $key => $value){ $config_file_contents.="define(\"{$key}\",\"{$value}\");\n"; And this is how it looks on the file it creates using fwrite define("GOOGLE_ANALYTICS","<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-40512701-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>"); Link to comment https://forums.phpfreaks.com/topic/277392-need-help-with-creating-constants-through-a-form/ Share on other sites More sharing options...
Jessica Posted April 28, 2013 Share Posted April 28, 2013 Try using heredoc syntax, not sure if it works for constants. Link to comment https://forums.phpfreaks.com/topic/277392-need-help-with-creating-constants-through-a-form/#findComment-1427010 Share on other sites More sharing options...
eldan88 Posted April 28, 2013 Author Share Posted April 28, 2013 Try using heredoc syntax, not sure if it works for constants. Thanks jess! Link to comment https://forums.phpfreaks.com/topic/277392-need-help-with-creating-constants-through-a-form/#findComment-1427019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.