+ Reply to Thread
Results 1 to 5 of 5

Thread: Constants may only evaluate to scalar values

  1. #1
    fake01 is offline x10Hosting Member fake01 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    24

    Constants may only evaluate to scalar values

    So, I created a little table with some server scripts which pretty much just shows what it does.

    However, when I load the page I get a warning:

    Constants may only evaluate to scalar values

    link

    The page is nothing special I'm just going through some steps to sort out a problem with another script of mine and decided to do other work while I'm at it, hence the table.

    Line 60 is essentially the first line of the table, or better yet:

    PHP Code:
    define('argv',                        $_SERVER['argv']); 
    I've done some reseach and from what I can see, the problem lies with having an old/outdated version of PHP.

    Is there any way in which this can be fixed without having to change the define(s)??

    ---------- Post added at 09:33 AM ---------- Previous post was at 05:06 AM ----------

    bump
    Last edited by fake01; 06-23-2010 at 12:07 AM.

  2. #2
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jun 2005
    Location
    Behind a keyboard.
    Posts
    8,998

    Re: Constants may only evaluate to scalar values

    From the documentation I was able to find it's nothing to do with the PHP version; there's a brutal way to fix it though.

    Prefix define with an @ so it's @define. That will suppress any warnings/errors generated by that line. That's assuming the line is working though; if the constant isn't being set properly to begin with then I'm not sure how to go about fixing it.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

  3. #3
    Zubair's Avatar
    Zubair is offline x10 Super Spammer Zubair has a reputation beyond reputeZubair has a reputation beyond reputeZubair has a reputation beyond repute
    Join Date
    Jul 2009
    Location
    Pakistan
    Posts
    8,747

    Re: Constants may only evaluate to scalar values

    ***Moved to Programming Help***
    Zubair Barkat | Level 2 Tech
    █ 888-X10-9668 - zubair[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004

  4. #4
    fake01 is offline x10Hosting Member fake01 is an unknown quantity at this point
    Join Date
    Dec 2009
    Posts
    24

    Re: Constants may only evaluate to scalar values

    Quote Originally Posted by Livewire View Post
    From the documentation I was able to find it's nothing to do with the PHP version; there's a brutal way to fix it though.

    Prefix define with an @ so it's @define. That will suppress any warnings/errors generated by that line. That's assuming the line is working though; if the constant isn't being set properly to begin with then I'm not sure how to go about fixing it.
    Ohh, I never thought about using the @ sign. I have used it before but never occurred to me when doing defines :D

    Cheers mate, will give it a crack.

  5. #5
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Constants may only evaluate to scalar values

    By nature define is only actually allowed to store simple string, float, bool or int values, nothing more; so no arrays, objects, etc. That code shouldn't work, and if it does you are using a feature/bug that is beyond the PHP specification and could break with any update. The better way to do it would be using global $varname or restructure how you access the required data.
    I suggest you read up about using the define() function on php.net.

+ Reply to Thread

Similar Threads

  1. Passing values
    By liguehs in forum Programming Help
    Replies: 3
    Last Post: 07-27-2009, 03:05 PM
  2. Scalar Vector Graphics
    By adatapost in forum Graphics & Webdesign
    Replies: 1
    Last Post: 02-11-2009, 04:43 PM
  3. Cannot pass values to PHP files ...
    By anuj_web in forum Programming Help
    Replies: 9
    Last Post: 04-14-2008, 07:07 AM
  4. [PHP] counting values in mysql_fetch_array()?
    By bonzo meier in forum Programming Help
    Replies: 4
    Last Post: 02-19-2008, 03:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers