Jump to content

[SOLVED] var and @


hongster

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.