Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/72261-solved-create-a-string-that-includes-the/
Share on other sites

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?

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 "\"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.