1

I downloaded Respect/validation zip file from here https://github.com/Respect/Validation/archive/master.zip

I unzipped the archive and added a php file named phpinfo.php @ /Validation-master/Validation-master/library/

this is the project structure enter image description here

the contents of the phpinfo file is

<?php
use Respect\Validation\Validator as v;

$usernameValidator = v::alnum()->noWhitespace()->length(1,15);

$valid = $usernameValidator->validate("alganet"); //$valid now == true
$valid = $usernameValidator->validate("ácido acético"); //$valid now == false
?>

I have an XAMPP installation running. I tried running the phpinfo.php file from my browser.

I am getting the Fatal error: Class 'Respect\Validation\Validator' not found in C:\xampp\htdocs\phpproj\boots\Dropbox\EasyAccounts\validation\Validation-master\Validation-master\library\phpinfo.php on line 4

What should I do to load the class ? I am a newbie in terms of PHP.

4

1 回答 1

1

You should either include the file or use an autoloader

于 2014-08-13T16:46:29.827 回答