RussellReal Posted December 18, 2008 Share Posted December 18, 2008 lets say I have this string '\n\t\r\n\n\x3C' is there a function which CAN properly handle each special escape char's special meaning.. I don't know how to explain it, I just hope someone can understand what I am trying to say.. I tried strip slashes but that just turns:\n\t\r\n\n\x3C into: ntrnnx3C and I want it to turn it into the special meanings Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/ Share on other sites More sharing options...
xtopolis Posted December 18, 2008 Share Posted December 18, 2008 Are you outputting it in single or double quotes? <?php echo '<pre>'; echo "\tTabbed(interpretted)"; echo '<br />'; echo '\tNot tabbed(literal)'; echo '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-718563 Share on other sites More sharing options...
RussellReal Posted December 18, 2008 Author Share Posted December 18, 2008 I know the difference between single and double quotes.. if I deliberately set my variable with single quotes.. and then I want to make it evaluate at a later time in the script.. how would I go about doing that? Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-718591 Share on other sites More sharing options...
xtopolis Posted December 18, 2008 Share Posted December 18, 2008 Then perhaps str_replace() using the same literal values? Can you post an example of what you have? Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-718610 Share on other sites More sharing options...
RussellReal Posted December 18, 2008 Author Share Posted December 18, 2008 okay.. lets give an example I have a text file called blah.txt which contains \x3cb\x3eOMG NO FREAKING WAY\x3c/b\x3e now when I do $e = file_get_contents("blah.txt"); $e will contain the contents, EXACTLY as it was in the text file.. I want the hex to evaluate, I want to know if there is a function to do so. Thank you very much foir your replies so far guys Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-718612 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 '\n\t\r\n\n\x3C' That is what bothers me. If you are inputting that with the single quotes, of course that is taken literally. Use double quotes "\n\t\r\n\n\x3C" And those characters will be put into their special meaning. Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-718693 Share on other sites More sharing options...
RussellReal Posted December 18, 2008 Author Share Posted December 18, 2008 lol... I KNOW what the difference in QUOTES are.. nvm forget I asked.. lol Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-719016 Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 lol... I KNOW what the difference in QUOTES are.. nevermind forget I asked.. lol Sorry about that, it is hard to know how much you know, especially since you are relatively new. Do you know how the text is being entered into the text file? Like is html_entities is being used or if it is being entered using utf8_encode ? Not sure of either of those would help you out or not.... Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-719083 Share on other sites More sharing options...
RussellReal Posted December 18, 2008 Author Share Posted December 18, 2008 Yeah, I really don't think theres a file, I'd have to pull something like eval("\$var = \"{$actualVar}\";"); to evaluate the \n \r you know the escaped characters, I just set up a str replace $image[] = str_replace(array('\x3c','\x3e','\x3d','\x26'),array('<','>','=','&'),substr($data,$q1 + 1,$start - ($q1 + 1))); Quote Link to comment https://forums.phpfreaks.com/topic/137498-solved-evaluating-an-escaped-string/#findComment-719086 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.