Skip to content

Instantly share code, notes, and snippets.

@netojoaobatista
Forked from Bolinha1/Usuario.php
Last active December 24, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netojoaobatista/6809209 to your computer and use it in GitHub Desktop.
Save netojoaobatista/6809209 to your computer and use it in GitHub Desktop.
<?php
$whereAmI = dirname(realpath(__FILE__)). DIRECTORY_SEPARATOR;
set_include_path(
implode(
PATH_SEPARATOR,
array_unique(
array_merge(
array(
$whereAmI . 'src',
$whereAmI . 'tests',
),
explode(PATH_SEPARATOR, get_include_path())
)
)
)
);
spl_autoload_register(
function ($qname)
{
$qname2path = stream_resolve_include_path(
str_replace('\\', DIRECTORY_SEPARATOR, $qname) . '.php');
if ($qname2path !== false) {
require $qname2path;
}
}
);
<?php
include 'autoload.php';
use classe\Usuario;
$u = new Usuario;
var_dump($u);
<?php
// dir classe/Usuario
namespace classe;
class Usuario
{
private $email;
private $senha;
public function setEmail($email)
{
$email = strtolower($email);
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
return false;
else
$this->email = $email;
}
public function getEmail()
{
return $this->email;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment