473,480 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

constant

Hi folk

I do this:

define("a1", "b");
echo a1
$y = 1;
$x = "a".$y
echo contant($x);

for the last line I get an error. How can I fix this?

Cheers

Nicolaas
Jan 21 '06 #1
5 1474
>
define("a1", "b");
echo a1
$y = 1;
$x = "a".$y
echo contant($x);

for the last line I get an error. How can I fix this?


Just check your spelling and punctuation!

define("a1", "b");
echo a1;
$y = 1;
$x = "a".$y;
echo constant($x);

It works.

Balazs
Jan 21 '06 #2
You're missing a semicolon on the line before the last - this will give
an error on the last line.

Jan 21 '06 #3
Balazs Wellisch wrote:
define("a1", "b");
echo a1
$y = 1;
$x = "a".$y
echo contant($x);

for the last line I get an error. How can I fix this?


Just check your spelling and punctuation!

define("a1", "b");
echo a1;
$y = 1;
$x = "a".$y;
echo constant($x);

It works.

Balazs


it was actually just an example. In real life it is not working! It is a
pretty old version of PHP, could that be it? It does recognise constant as
a function though. It was all rather weird.
Jan 21 '06 #4
"windandwaves" <wi*********@coldmail.com> kirjoitti
viestissä:1g********************@news.xtra.co.nz.. .
Balazs Wellisch wrote:
define("a1", "b");
echo a1
$y = 1;
$x = "a".$y
echo contant($x);

for the last line I get an error. How can I fix this?


Just check your spelling and punctuation!

define("a1", "b");
echo a1;
$y = 1;
$x = "a".$y;
echo constant($x);

It works.

Balazs


it was actually just an example. In real life it is not working! It is a
pretty old version of PHP, could that be it? It does recognise constant
as a function though. It was all rather weird.


Constant() function is available since php 4.0.4
http://fi.php.net/manual/en/function.constant.php

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <an*******************@gmail.com.NOSPAM.invalid>
Jan 21 '06 #5
It could be a bug. Try defining the constant as case-insensitive and
see what happens. Got a dump on get_defined_constants() too.

Jan 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1884
by: Andrea M. Segovia | last post by:
I just compiled (but did not install) perl 5.8.0 on an SGI Origin 300 server (IP35) running IRIX 6.5.20m. Make test reported one test error, which I narrowed down to .../lib/ExUtils/t/Constant.t...
6
35647
by: fctk | last post by:
hello, i'm trying to compile this small program: int main(void) { unsigned long int max; max = 4000000000;
25
2538
by: tsaar2003 | last post by:
Hi Pythonians, To begin with I'd like to apologize that I am not very experienced Python programmer so please forgive me if the following text does not make any sense. I have been missing...
3
2331
by: lovecreatesbeauty | last post by:
Both `K&R C, 2nd' and `C: A reference manual, 5th' introduce the "hello, world" thing using the name "string-constant". But `ISO/IEC 9899:TC2' does not include this kind of thing in section `A.1.5...
25
5656
by: galapogos | last post by:
Hi, I'm trying to compare an array of unsigned chars(basically just data without any context) with a constant, and I'm not sure how to do that. Say my array is array and I want to compare it with...
33
5508
by: desktop | last post by:
In the C++ standard sec 23.1.2 table 69 it says that erase(q) where q is a pointer to an element can be done in amortized constant time. I guess that is not worst case since std::set is...
18
1911
by: sinbad | last post by:
hi, why does the following program gives an runtime error ,instead of compilation error. anyone please shed some light. thanks sinbad ------------------------------ int main()
3
4744
by: Dan Smithers | last post by:
What constitutes a constant-expression? I know that it is something that can be determined at compile time. I am trying to use template code and keep getting compiler errors "error: cannot...
7
2789
by: John Koleszar | last post by:
Hi all, I'm porting some code that provides compile-time assertions from one compiler to another and ran across what I believe to be compliant code that won't compile using the new compiler. Not...
7
4245
by: Hendrik Schober | last post by:
Hi, this #include <string> class test { typedef std::string::size_type size_type; static const size_type x = std::string::npos; }; doesn't compile using either VC9 ("expected constant...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7022
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.