Matching quote?
Posted: Sun Sep 25, 2005 10:24 am
Code: Select all
$pattern = "#^[']+$#";A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$pattern = "#^[']+$#";Code: Select all
''''''''''''''Code: Select all
'''a''''''''Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form method="post" action="http://192.168.0.153/test/test.php">
<table class="form_table med_bg">
<tr>
<td><label>Value:</label></td>
<td><input type="text" name="value" /></td>
</tr>
<tr>
<td><span> </span></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>Code: Select all
include('class.Validator.php');
$validator = &new Validator();
if ($validator->isName($_POST['value']))
{
echo 'Valid.';
} else
{
echo '<b>Invalid!</b>';
}Code: Select all
class Validator
{
function Validator()
{
}
function isName($value)
{
$pattern = "#^[']+$#";
$matches = preg_match($pattern, $value);
if ($matches > 0)
{
return true;
}
return false;
}
}"#'{1,}+#"