This is the error I am receiving:
Fatal error: Class 'Validate' not found in C:\xampp\htdocs\final_project\validate.php on line 5
And here is my PHP code:
<?php
require_once 'Validate.php';
foreach($_POST as $name => $value)
{
$valid = Validate::string($value);
}
?>
I do not understand what I am missing. I installed –alldeps for the validate package, and the PEAR include path is also correct. Validate_CA is not giving me any errors, but it is not properly validating either.
PHP parses the
include_pathin order of precedence. This means that when a relative path is passed torequire(),include(),fopen(),file(),readfile()orfile_get_contents(), PHP will start looking in the first directory. If the file is found, it includes it. If not, it will continue to the next and repeats the process.Consider the following include path:
and the following PHP script:
PHP will look for
MyFile.phpin the following order:./MyFile.php(Current Directory)/php/includes/MyFile.php/php/pear/MyFile.phpThe reason why you cannot load
Validate.phpis you already have a file calledvalidate.php(remember, paths are not case-sensitive on Windows, but are on UNIX) in your current directory. Therefore, PHP includes your file instead of the file corresponding toPEAR::Validatesince yours is found before PEAR’s in theinclude_pathorder of precedence.Simply renaming your file to something else than
validate.phpshould fix your problem. If it still doesn’t work, try echoing the return value ofget_include_path()to make sure it really is set right.