I am amending my previous statement. You cannot use multiple "else" in an "elseif" statement.
If someone else knows better, please correct me if I am wrong
Printable View
I am amending my previous statement. You cannot use multiple "else" in an "elseif" statement.
If someone else knows better, please correct me if I am wrong
How to do then?
Just read my post and you will see the answer as well as a sample script. You can also read more about it at http://php.net/manual/en/control-structures.elseif.php
what if I have more than 3 statements and if's?
Code:<?php
if (preg_match('/\W/', $password)) {
echo "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected!!!</b></font></center>";
$string = '1';
}
elseif (preg_match('/\W/', $nick)) {
echo "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>";
$string = '1';
}
elseif (preg_match('/\W/', $occupation)) {
echo "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>";
$string = '1';
}
elseif (preg_match('/\W/', $name)) {
echo "<center><font size='1' face='Verdana' color='blue'><b>!!! Symbols detected !!!</b></font></center>";
$string = '1';
}
else $string = '0';
if ($string == 1) die;
else work;
?>
ok, i'll try... Thanks.
preg_mach doesnt work for me... it isnt detecting symbols... idk why, but in other page it works
what i have to write in here:
(preg_match('/\W/', $password)
if I want to detect 'word characters', 'numbers', 'underscores', '@' , '.' , and ',' ??
I suspect that you are racing into this a bit too fast. regular expressions is one of the most complex aspects of php and takes a little time to understand.
\w is the opposite of \W.
\w will match word characters. Word characters is defined as all letters, numbers, and the underscore.
The following will detect whether any letters, numbers, underscores, periods, commas, or 'at' symbols are found in your string.
The square brackets says that the things we want to find between them can be in any order.Code:<?php
$test='.,@';
if(preg_match('/[\w,.@]/', $test))
{echo "YES, there was at least one word character ',', '.' or '@' symbol detected.";}
else
{echo "NO there was not one word character ',', '.' or '@' symbol detected.";}
?>
maybe, because i used this a lot:
$tag = str_replace('*', '/*', $tag);
and i dont know how to change ' symbol to /'
if i write like that:
$tag = str_replace('' '/'', $tag); it will be bad :)