php - Retrieving data inside a function -
i trying user info using cakephp find within php function, it's phone call function.
is there way info within phone call function?
here getting error "using $this when not in object context"
public function links($msg=null){ $final_message = preg_replace(array('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))/', '/(^|[^a-z0-9_])#([a-z0-9_]+)/i'), array('<a href="$1" target="_blank">$1</a>', '$1<a href="/getdatabyhash/$2">#$2</a>'), $msg); $regex = '~(?i)@[a-z]+[ ][a-z]+~'; $replaced = preg_replace_callback($regex,function ($match) { foreach($match $stringmatch) { $username= preg_replace('/@/',"",$stringmatch); $fetchuser=$this->user->find('all', array('conditions'=> array("user.first_name like" => "%$username%"))); if(sizeof($fetchuser)> 0) { homecoming "<a href='@'>@</a>"; } else { } }
try
app::uses('classregistry', 'utility'); class whatever etc.{ protected $user; public function __construct(){ $this->user = classregistry::init('user'); } }
php cakephp-2.0
No comments:
Post a Comment