<?php
class User {
public $name;
public $age;
public static $minPassLength = 6;
public static function validatePass($pass){
if(strlen($pass) >= self::$minPassLength) { //self because it's static
return true;
} else {
return false;
}
}
}
$password = 'hello';
if(User::validatePass($password)) {
echo 'Password valid';
} else {
echo 'Password not valid';
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter