UrunController.php
public function kontrolAction(){
$kk = new urunler();
$kk->kodkontrol($this->request->getPost());
echo $kk;
}
urunler.php
public function kodkontrol(){
while(1){
$UrunKodu = chr(rand(65,90)).chr(rand(65,90)).'-'.rand(1,9999);
$UKKontrol = $this->findFirst("urunBarkod = '{$UrunKodu}'");
if($UKKontrol > 0){
continue;
} else{
break;
}
}
echo $UrunKodu;
}
答案 0 :(得分:1)
实际上,我认为一种方法永远不应该echo
。更好的方法是return
某事。但无论如何,如果你想回显一个对象,你应该看一下__toString()
方法。