When to use __LINE__ , __FUNCTION__, and __CLASS__ ??
Moderator: General Moderators
When to use __LINE__ , __FUNCTION__, and __CLASS__ ??
I've read up on __LINE__, __CLASS__, and __FUNCTION__, but I can't seem to figure out why and where to use them? Could anyone shed some light on this for me? Thanks
Those constants vars are typically used with error checking.
Code: Select all
....
if($error){
echo 'Error in '.__FUNCTION__.' Function ';
}yeah, but i've seen them used for passing data?
?? so i can't undersstand why __LINE__ would be passed. or either of the other 2 constants?
Code: Select all
$blah = __CLASS__.'::'.__FUNCTION;
$a->query($string,$blah,__LINE__);you could put them in an error class.
Code: Select all
do_this() or uhoh(__CLASS__,__FUNCTION__,__LINE__);- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
dunno why they would pass __LINE__ in a query unless you want to do somtin like thismudvein wrote:yeah, but i've seen them used for passing data?
?? so i can't undersstand why __LINE__ would be passed. or either of the other 2 constants?Code: Select all
$blah = __CLASS__.'::'.__FUNCTION; $a->query($string,$blah,__LINE__);
Code: Select all
$do_query = mysql_query($query) or die(mysql_error().__LINE__);Can you show an example of where you saw this code? Maybe that will help...?mudvein wrote:yeah, but i've seen them used for passing data?
?? so i can't undersstand why __LINE__ would be passed. or either of the other 2 constants?Code: Select all
$blah = __CLASS__.'::'.__FUNCTION; $a->query($string,$blah,__LINE__);