Validating Pascal Case Names
<?php
$values = array(
"PascalCase", // Valid
"_notvalid", // Not Valid
);
foreach ($values as $value) {
if(preg_match("/^([A-Z][a-z]+)+$/", $value)) {
printf("'%s' is a valid name.\n", $value);
} else {
printf("'%s' is NOT a valid name.\n", $value);
}
}
?>
Related examples in the same category