Re: [PHP] reporting errors when $ sign is missing in front of a variable

2012-01-12 Thread Mihai Anghel
Also, you get the output my_var because if you say echo my_var PHP
looks for a constant my_var and if it doesn't find one it just assumes
you want the name of the constant.Look in the manual page for
constants for more details about how they work
http://php.net/manual/en/language.constants.php

On Thu, Jan 12, 2012 at 9:57 AM, ma...@behnke.biz ma...@behnke.biz wrote:

 Haluk Karamete halukkaram...@gmail.com hat am 12. Januar 2012 um 06:17
 geschrieben:

 Thanks...
 Well I just changed the ?php error_reporting (E_ALL ^ E_NOTICE); ?
  to ?php error_reporting (E_ALL ); ?  and that does it for me.

 Notice: Use of undefined constant my_age - assumed 'my_age' in
 D:\Hosting\5291100\html\blueprint\bp_library.php on line 40
 my_age

 Now back in business :)

 If you are programming with an IDE, it does the work for you. While 
 programming
 you will see warning notices, that you are refering to something unknown.


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


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



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

2012-01-11 Thread Haluk Karamete
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



Re: [PHP] reporting errors when $ sign is missing in front of a variable

2012-01-11 Thread Tommy Pham
On Wed, Jan 11, 2012 at 8:43 PM, Haluk Karamete halukkaram...@gmail.com wrote:

 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



This works for me in development environment without a debugger setup
using a web browser (note that I'm using 5.4RC2 so the default
behavior of error_reporting(E_ALL) is different [1]:

Notice: Use of undefined constant my_var - assumed 'my_var' in
F:\dev\sites\wwwroot\php_apps\test.php on line 5
my_var ?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$my_var = 90;
echo my_var;

highlight_file(__FILE__);

Good luck,
Tommy

[1] http://php.net/function.error-reporting

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



Re: [PHP] reporting errors when $ sign is missing in front of a variable

2012-01-11 Thread Haluk Karamete
Thanks...
Well I just changed the ?php error_reporting (E_ALL ^ E_NOTICE); ?
 to ?php error_reporting (E_ALL ); ?  and that does it for me.

Notice: Use of undefined constant my_age - assumed 'my_age' in
D:\Hosting\5291100\html\blueprint\bp_library.php on line 40
my_age

Now back in business :)


Notice: Use of undefined constant my_age - assumed 'my_age' in
D:\Hosting\5291100\html\blueprint\bp_library.php on line 40my_age
On Wed, Jan 11, 2012 at 9:12 PM, Tommy Pham tommy...@gmail.com wrote:
 On Wed, Jan 11, 2012 at 8:43 PM, Haluk Karamete halukkaram...@gmail.com 
 wrote:

 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



 This works for me in development environment without a debugger setup
 using a web browser (note that I'm using 5.4RC2 so the default
 behavior of error_reporting(E_ALL) is different [1]:

 Notice: Use of undefined constant my_var - assumed 'my_var' in
 F:\dev\sites\wwwroot\php_apps\test.php on line 5
 my_var ?php
 error_reporting(E_ALL);
 ini_set('display_errors', 'on');
 $my_var = 90;
 echo my_var;

 highlight_file(__FILE__);

 Good luck,
 Tommy

 [1] http://php.net/function.error-reporting

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



Re: [PHP] reporting errors when $ sign is missing in front of a variable

2012-01-11 Thread ma...@behnke.biz
 
Haluk Karamete halukkaram...@gmail.com hat am 12. Januar 2012 um 06:17
geschrieben:

 Thanks...
 Well I just changed the ?php error_reporting (E_ALL ^ E_NOTICE); ?
  to ?php error_reporting (E_ALL ); ?  and that does it for me.

 Notice: Use of undefined constant my_age - assumed 'my_age' in
 D:\Hosting\5291100\html\blueprint\bp_library.php on line 40
 my_age

 Now back in business :)
 
If you are programming with an IDE, it does the work for you. While programming
you will see warning notices, that you are refering to something unknown.
 

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