<?php
class User {
protected $id;
public $dados;
public function __construct($id) {
$this->id = $id; // aqui já tens o teu id
// echo $this->id; // vai imprimir 4 e podes fazer o que quiseres com ele ao longo dos metodos/atributos desta instância
// aceder à base de dados, SELECT * FROM users WHERE id = $id, 4 neste caso
// depois já terás os dados que queres acerca do utilizador
$this->dados = array('id' => 4, 'nome' => 'Miguel', 'email' => 'hdj@jdj.di'); }
}
$u = new User(4);
echo $u->dados['email']; // hdj@jdj.di
PD9waHAKY2xhc3MgVXNlciB7CgogICBwcm90ZWN0ZWQgJGlkOwogICBwdWJsaWMgJGRhZG9zOwogICBwdWJsaWMgZnVuY3Rpb24gX19jb25zdHJ1Y3QoJGlkKSB7CiAgICAgICR0aGlzLT5pZCA9ICRpZDsgLy8gYXF1aSBqw6EgdGVucyBvIHRldSBpZAogICAgICAvLyBlY2hvICR0aGlzLT5pZDsgLy8gdmFpIGltcHJpbWlyIDQgZSBwb2RlcyBmYXplciBvIHF1ZSBxdWlzZXJlcyBjb20gZWxlIGFvIGxvbmdvIGRvcyBtZXRvZG9zL2F0cmlidXRvcyBkZXN0YSBpbnN0w6JuY2lhCiAgICAgIC8vIGFjZWRlciDDoCBiYXNlIGRlIGRhZG9zLCBTRUxFQ1QgKiBGUk9NIHVzZXJzIFdIRVJFIGlkID0gJGlkLCA0IG5lc3RlIGNhc28KCiAgICAgIC8vIGRlcG9pcyBqw6EgdGVyw6FzIG9zIGRhZG9zIHF1ZSBxdWVyZXMgYWNlcmNhIGRvIHV0aWxpemFkb3IKICAgICAgJHRoaXMtPmRhZG9zID0gYXJyYXkoJ2lkJyA9PiA0LCAnbm9tZScgPT4gJ01pZ3VlbCcsICdlbWFpbCcgPT4gJ2hkakBqZGouZGknKTsKICAgfQp9CgokdSA9IG5ldyBVc2VyKDQpOwplY2hvICR1LT5kYWRvc1snZW1haWwnXTsgLy8gaGRqQGpkai5kaQ==