hongster Posted March 30, 2007 Share Posted March 30, 2007 When do we use 'var' for variable declaration? When do we use the symbol '@'? What is it for? Link to comment https://forums.phpfreaks.com/topic/44885-solved-var-and/ Share on other sites More sharing options...
Lumio Posted March 30, 2007 Share Posted March 30, 2007 You use var in classes. For example: <?php class MYCLASS { var $myvar = 'foo'; } $c = new MYCLASS; echo $c->myvar; ?> So that's a property. Every function can use it. If you only declair it in a function, other function can't use them. The @ is to ignore php-errors. Another example: <?php echo (10 / 0); //division by 0 ?> You'll get a warning like Warning: Division by zero in /Users/lumio/Sites/temp.php on line 2 So try <?php echo @(10 / 0); ?> Now the warning gets ignored Link to comment https://forums.phpfreaks.com/topic/44885-solved-var-and/#findComment-217946 Share on other sites More sharing options...
hongster Posted March 30, 2007 Author Share Posted March 30, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/44885-solved-var-and/#findComment-217950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.