S开发者_如何学Pythono I got this error:
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\scanner\mine.php on line 112
On this line:
if(preg_match("inurl:", $text) {
Its part of a "Clean" function:
function Clean($text) {
if(preg_match("inurl:", $text) {
str_replace("inurl:", "", $text);
return htmlspecialchars($text, ENT_QUOTES);
} else {
return htmlspecialchars($text, ENT_QUOTES);
}
}
How can I fix it?
Two problems, One closing ) and a missing semicolon after str_replace, also you should know your str_replace won't do anything in your code so i added $text = ... :)
function Clean($text) {
if(preg_match("inurl:", $text)) {
$text = str_replace("inurl:", "", $text);
return htmlspecialchars($text, ENT_QUOTES);
} else {
return htmlspecialchars($text, ENT_QUOTES);
}
}
Add another )
:
if(preg_match("inurl:", $text)) {
You're missing the closing )
on your if statement.
Should be:
if(preg_match("inurl:", $text)) {
You're also missing your statement terminator on the string replace. That should be:
str_replace("inurl:", "", $text);
You left out the )
for the if
condition.
if
(
preg_match(
"inurl:", $text
)
{
The if clause is superfluous anyway. The following function is equivalent to the original version (sans the non-compiling regex pattern).
function Clean($text)
{
$text = str_replace("inurl:", "", $text);
return htmlspecialchars($text, ENT_QUOTES);
}
If the string you want to replace is not found in the haystack, str_replace won't do anything. So it is safe to run the function unconditionally.
In the original version, you'd also have to surround the regex pattern for preg_match with delimiters (see: http://www.php.net/manual/en/regexp.reference.delimiters.php). (In this case, strpos would do the job, too.)
精彩评论