okay, its a simple question, but I have no idea how to search for this.
How can I put a forward slash within quotes.
I have a problem, a string gets converted to "xyz\" and is then put in an sql querry, how can I detect the slash, I cant use: strpos($encPass, "\" ) > -1
Since the \ makes the quotation a non surrounding quotaion.. so what can I use to detect a forward slash?
"/" how to do this within php - Forward slahes
Moderator: General Moderators
You escape it.
"\\"
"\\"
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Use substr() http://php.net/substr
to check last char of a string
and remove if backslash
The tricky thing is that '\' has to be escaped with one: '\'
to check last char of a string
and remove if backslash
The tricky thing is that '\' has to be escaped with one: '\'
Code: Select all
<?php
// a backslash has to be escaped by one: '\'
$string = 'xyz\\';
// see if last char is '\'
// -1 means last char. 1 means length = 1 char to test
if( substr( $string, -1, 1 ) == '\\')
// From 0 first char, to length -1
$string = substr( $string, 0, -1 );
echo $string;
?>