Php Newbie, bit of help needed - undefined notices

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Fri Jun 28, 2013 8:45 pm

To explain this error, you need to understand about arrays in php.

Let see an example: Suppose I want to store the quatity of fruits in a shop in an array. For this I will
create an array like this:

Code: Select all

$fruits = array();
$fruits['apple'] = 120;
$fruits['orange'] = 60;
$fruits['pear'] = 220;
To access the count of these fruits you will do:

Code: Select all

echo " Count of orange is ".$fruits['orange'];
echo " Count of apple is ".$fruits['apple'];
echo " Count of pear is ".$fruits['pear'];
Let us try to access the count of "lemon";

Code: Select all

echo " Count of Lemon is ".$fruits['lemon'];
But lemon is not there in our array and php will throw the "undefined" notice.
Similarly php will again throw undefined notice if you try to display $fruits['99'];

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Fri Jun 28, 2013 8:46 pm


johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Sat Jun 29, 2013 6:00 am

There isn't anything like "the best book". The ideal one is the manual on php.net.

There are plenty of "good" books. One of them is here
http://phillipnb.wordpress.com/2012/09/ ... beginners/

Beginning PHP by Doyle is another good one

Another one is Programming PHP by Kevin Tatroe, Peter MacIntyre and Rasmus Lerdorf

Another one Beginning PHP and MySQL: From Novice to Pr...by W. Jason Gilmore

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests