hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : (PHP) Notice: Use of undefined constant
Reply

Forum Jump

(PHP) Notice: Use of undefined constant

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-27-2005, 01:41 AM
Trilogen Trilogen is offline
Newbie
 
Join Date: Sep 2004
Location: Sydney
Posts: 7
Question

(PHP) Notice: Use of undefined constant


I'm a noob here, reading through SAMs PHP & MySQL Web Development. I can't get around this problem.

PHP Code:
$products = array( array("TIR""Tires"100),
        array( 
"OIL""Oil"10),
        array( 
"SPK""Spark Plugs"4));

function 
compare($x$y)
{
    if ( 
$x[1] == $y[1] )
        return 
0;
    else if ( 
$x[1] < $y[1] )
        return -
1;
    else
        return 
1;
}

usort($productscompare); 
I'ts supposed to sort the arrays inside $products

Outputs:

Notice: Use of undefined constant compare - assumed 'compare' in C:\Inetpub\wwwroot\PHP\usort.php on line 16



Sponsored Links
  #2  
Old 01-27-2005, 02:05 AM
Burhan Burhan is offline
Community Guide
 
Join Date: Jul 2003
Location: Kuwait
Posts: 5,099
Change to usort($products, 'compare');

Any string not encapsulated in quotes is considered a constant, and that message is just a Notice telling you that PHP thinks compare is a constant, but its not defined anywhere.

__________________
In order to understand recursion, one must first understand recursion.
If you feel like it, you can read my blog
Signal > Noise

  #3  
Old 01-27-2005, 02:28 AM
Trilogen Trilogen is offline
Newbie
 
Join Date: Sep 2004
Location: Sydney
Posts: 7
That did the trick, thanks fyre!

Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Tech Companies Pledge Not to Remain Silent About Customer Data Requests Web Hosting News 2014-05-06 10:21:05
Western Digital Suffers Prolonged My Cloud Service Disruption Web Hosting News 2014-04-05 08:49:58
Technicians Work to Bring Department Store Website Online for Holiday Shopping Season Web Hosting News 2013-12-27 14:06:04
Sophos Launches Cloud-Based Managed Security Service Web Hosting News 2013-10-29 17:53:59
Web Hosting Sales and Promos Roundup – July 26, 2013 Web Hosting News 2014-05-23 15:42:54


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?