J'ai un problème avec la transmission d'un objet à smarty tag. J'ai le code suivant:Transférer l'objet php à smarty
$contact = new Contacts;
$smarty = new Smarty;
$smarty->assign('contact',$contact);
En test.htpl:
<html>
<head>
<title>{$title}</title>
</head>
<body>
id: {$contact->id} <br/>
name: {$contact->name} <br/>
email: {$contact->email} <br/>
phone: {$contact->phone} <br/>
</body>
</html>
ce qui conduit à un avertissement de caractère non valide '>'. Comment puis-je resoudre ceci?
J'ai utilisé cette classe pour les tests:
class Contacts
{
public $id = 1;
public $name = 'Mada';
public $email = '[email protected]';
public $phone = 123456;
}
pouvez-vous nous montrer ce que nous dans la classe Contacts? – RJD22
Googling "smarty modèle objet" conduire à http://www.smarty.net/manual/fr/advanced.features.php comme le premier résultat. – zneak