class - Php Classes Unique Data Member -


i'm new in php, our instructor teaching c++ oop , want try on php.

i'm creating objects class.

class twitteruser {      private $twittername;     public function twitteruser($a)     {         $this->twittername = $a;         // echo $this->twittername;       }  }      $reader = new spreadsheet_excel_reader($target_path);  $veriler = $reader->sheets[0]['cells']; foreach($veriler $veri) { if(!empty($veri[$sutun]) , $veri[$sutun]!="twitter")     {     $kisiler[] = new twitteruser(temizle($veri[$sutun]));      } } 

what want is, if 1 object has same string other object in $twittername data member, don't create new object.

this task done using kind of model -> database approach (such doctrine), in case save model data database. database table should designed not allow same name more 1 record , logic enforce , error handle can built model class.

you can achieve same pure php, requires existing instances stored somehow when creating new instances, existing ones can checked uniqueness.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -