PHP Validating Pascal Case Names – String Function

<?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);
    }
  }?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.