reporting errors when $ sign is missing in front of a variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I'm coming from ASP background.
There, there is a life saver option called "option explicit". It
forces you to declare your variables using the "dim" statement. The
good thing about that is that if you were to mis-spell one of your
variables, asp.dll throws an error stating that on line so and so,
variable so and so not declared. This allows you to immediately fix
the error saving lots of time. If you did not use "option explicit",
then that misspelled variable would not have caused any error and you
woud have spent much more time debugging your app as to what went
wrong where.

Now, I undersand with PHP, that we do not have a variable declaration
per se; you put a $ sign in front of a word, and that becomes a
variable. Since in asp, we do not use $ much. I keep forgetting that.
I first declare a var and set a value for it using the $. But then I
refer to the darned thing, without the $. And there are no errors. Ths
behaviour seems extremely odd to me.

How do I achieve the functionality that if I forget to use $ sign for
a previously declared variable, php throws me an error.

example

$my_var = 90;
echo my_var;

I want an error to be thrown in line 2. what do I need to do?"
I was assuming  that since there is no function titled "my_var", PHP
would have complain right there and then. But instead, it simply
echoes "my_var".

I would have expected "my_var" to be outputted only if I were to write
echo "my_var";. This beats me.

At the top of my page, I already have this <?php error_reporting
(E_ALL ^ E_NOTICE); ?>

Haluk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux