I need to output a string, which is basically a java code:
I have something like this:
$web = "...if (url.contains('.mp4'))..."
I need that the single quotation mark, will be a double one, and not in html code.
Is it possible to do it?
The basic double-quoted string is a series of characters surrounded by double quotes. If you need to use the double quote inside the string, you can use the backslash character. Notice how the backslash in the second line is used to escape the double quote characters.
\" - escape sequence Since printf uses ""(double quotes) to identify starting and ending point of a message, we need to use \" escape sequence to print the double quotes.
$new_str = str_replace('\'', '"', $web);
You could optional do it by modifying the actual string (note the use of \
to escape the quotation marks):
$web = "...if (url.contains(\".mp4\"))..."
You can use like this
$web = "...if (url.contains(\".mp4\"))...";
Short of doing a strtr()
replacement, just escape your double quotes:
$web = "...if (url.contains(\".mp4\"))..."
See http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double for the complete list of escaping rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With