Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've started playing on a php scripting following cbt video of Dean Davis. I'm using now XAMPP as my testing area of the codes. For some reason there is a section on the video where I'm testing the UNSET variable and brings me this error:
Code:
Notice: Undefined index: version in C:\xampp\htdocs\qq.php on line 18
strangely from the video provided it should not throw an error.
Which distro are you using? It would be easier for you and easier for people to help you if you work with the normal LAMP stack which is provided in your distro's repository. The directions vary depending on which distro you have but they are all quick and low-effort to install.
XAMPP is for Windows and those that try to shoehorn it onto GNU/Linux find that it costs a lot of extra work and headache.
That said, if I recall PHP, the blocks of code should start with '<?php' instead of '<?' alone.
Which distro are you using? It would be easier for you and easier for people to help you if you work with the normal LAMP stack which is provided in your distro's repository. The directions vary depending on which distro you have but they are all quick and low-effort to install.
XAMPP is for Windows and those that try to shoehorn it onto GNU/Linux find that it costs a lot of extra work and headache.
That said, if I recall PHP, the blocks of code should start with '<?php' instead of '<?' alone.
I'm using windows 7 with xampp lite v3.2.2
with regards on the <?php instead of '<?' I already managed to enable short tags on and worked out
You've unset the variable (destroyed it) and then asked PHP to print the variable out. It can't do this because you've just unset it, it doesn't exist any more.
You've unset the variable (destroyed it) and then asked PHP to print the variable out. It can't do this because you've just unset it, it doesn't exist any more.
I have no idea what the video is telling you to do, apss_evaluator. All I know is that you've unset an array element and then you're trying to print that array index, hence the error. PHP can't find the index "version" in the $arr1 array because it doesn't exist any more.
You can test for the existence of an array index using the function I referred to.
mozilla firefox0.9.1
netscape
Notice: Undefined index: version in C:\xampp\htdocs\qq.php on line 18
This is the expected output. I tested in PHP 5.5.6 and got the same result. I see what he's trying to prove - that if you unset the variable, then there's nothing to display. That's essentially what you successfully proved by receiving that notice.
Either the instructor has notice reporting turned off somewhere (as keefaz suggested), or perhaps he's using an older version of PHP that doesn't throw the notice. I can't tell you when or if there was a version where this notice wouldn't show up, but I don't remember there ever being a case where what you're trying to do didn't throw that notice.
Why it should be like this? echo'ing a non existent array item leads to unknown, your php setup throws notice on standard out, while in some other configs it will seem to be silent (like in your video) but notice will be seen on server errors log etc...
Imho it isn't good programming practice to print null variable, in some other language, this error could lead to quit program abruptly.
This is the expected output. I tested in PHP 5.5.6 and got the same result. I see what he's trying to prove - that if you unset the variable, then there's nothing to display. That's essentially what you successfully proved by receiving that notice.
Either the instructor has notice reporting turned off somewhere (as keefaz suggested), or perhaps he's using an older version of PHP that doesn't throw the notice. I can't tell you when or if there was a version where this notice wouldn't show up, but I don't remember there ever being a case where what you're trying to do didn't throw that notice.
You're right the instructor is using php 5.0.2, appears to be way back old version. understood it now. thanks :-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.