thewooleymammoth Posted October 8, 2007 Share Posted October 8, 2007 i cant put it the \ in quotes because it then exits. <?php array("\"); ?> should i put it like this? array("whatever", \, "whatever else"); i intend to use this for str_replace so would it read it like that? thanks Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/ Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 Either... <?php $str = "this is s string with a \\ backslash in it."; // or $str = 'this is s string with a \ backslash in it.'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/#findComment-364381 Share on other sites More sharing options...
thewooleymammoth Posted October 8, 2007 Author Share Posted October 8, 2007 Either... <?php $str = "this is s string with a \\ backslash in it."; // or $str = 'this is s string with a \ backslash in it.'; ?> yes but i want the string to only contain "\" and when the backslash is placed next to a quote doesnt it automatically ignore the end quote? Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/#findComment-364382 Share on other sites More sharing options...
trq Posted October 8, 2007 Share Posted October 8, 2007 Do you want your string to contain " and \ and " ? Your not being very clear. <?php $str = '"\"'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/#findComment-364384 Share on other sites More sharing options...
yzerman Posted October 8, 2007 Share Posted October 8, 2007 ok, using a slash in a string enclosed in quotes - cancels out the next character. So basically to have it echo \ literally, you will have to cancel out the slash to be taken literally with a preceeding slash. example: echo "\n"; //returns a newline character echo "\\n"; //returns \n So if you want it to echo a \: echo "\\"; //returns \ If you literally want "\": echo "\"\\\""; //returns "\" Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/#findComment-364386 Share on other sites More sharing options...
thewooleymammoth Posted October 8, 2007 Author Share Posted October 8, 2007 exactly what i needed, thanks a bunch. makes perfect sence now Quote Link to comment https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/#findComment-364389 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.