Got the following error when importing a PEAR class (Validate) into my namespace diversen
Cannot redeclare class Validate
In order to include a 3. part class without namespaces (like PEAR classes) into your namespace you can to do the following:
<?php
namespace diversen;
include_once 'Validate.php';
// to prevent Fatal error:
// Cannot redeclare class Validate
// use Validate as e.g. pearValidate;
use Validate as pearValidate;
But is is much simpler to write:
\Validate
Or:
use Validate
Validate
When using the class!
This page has been requested 6783 times