开发者

PHP PEAR Validate Package - Fatal error: Class 'Validate' not found

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 开发者_如何学Goany errors, but it is not properly validating either.


PHP parses the include_path in order of precedence. This means that when a relative path is passed to require(), include(), fopen(), file(), readfile() or file_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:

include_path = ".:/php/includes:/php/pear"

and the following PHP script:

<?php
require('MyFile.php');

PHP will look for MyFile.php in the following order:

  • ./MyFile.php (Current Directory)
  • /php/includes/MyFile.php
  • /php/pear/MyFile.php

The reason why you cannot load Validate.php is you already have a file called validate.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 to PEAR::Validate since yours is found before PEAR's in the include_path order of precedence.

Simply renaming your file to something else than validate.php should fix your problem. If it still doesn't work, try echoing the return value of get_include_path() to make sure it really is set right.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜