Constants may only evaluate to scalar values

fake01

New Member
Messages
24
Reaction score
0
Points
0
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:
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:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
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.
 

Zubair

Community Leader
Community Support
Messages
8,766
Reaction score
305
Points
83
***Moved to Programming Help***
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
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.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
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.
 
Top