473,511 Members | 15,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

arrays, constants, booleans, arithmetic values

define('P_START_YES', 1, FALSE);
define('P_START_NO', 0, FALSE);
define('P_END_YES', 2, FALSE);
define('P_END_NO', 0, FALSE);
define('APPEND_NL', 4, FALSE);

$aMenus = array(
array(0, 'http://www.example.com/', 'Example 001', P_START_YES || P_END_YES || APPEND_NL),
array(1, 'http://www.example.net/', 'Example 002', P_START_YES || P_END_YES || APPEND_NL)
);

I tried enclosing those values above (P_START_YES, et al) in parenthesis
but PHP complains that it expects a terminating parenthesis. I think this
may be a problem with the latest version of PHP. Why can't I put those
CONSTANTS in parenthesis and use the OR, or | or || to create values?

I was hoping to combine that into one value, rather than use three
separate fields to hold the values. And it seems strange that I'd need
to do like this...

$iTags = P_START_YES || P_END_YES || APPEND_NL;
// blah... I do not see the means at the moment, it's not in a foreach() loop.

--
Jim Carlock
You Have More Than Five Senses
http://www.associatedcontent.com/art...ve_senses.html

Oct 6 '08 #1
5 1280
..oO(Jim Carlock)
>define('P_START_YES', 1, FALSE);
define('P_START_NO', 0, FALSE);
define('P_END_YES', 2, FALSE);
define('P_END_NO', 0, FALSE);
define('APPEND_NL', 4, FALSE);

$aMenus = array(
array(0, 'http://www.example.com/', 'Example 001', P_START_YES || P_END_YES || APPEND_NL),
array(1, 'http://www.example.net/', 'Example 002', P_START_YES || P_END_YES || APPEND_NL)
);

I tried enclosing those values above (P_START_YES, et al) in parenthesis
but PHP complains that it expects a terminating parenthesis.
Works here (5.2.6), but the operator should be |, not ||.

Micha
Oct 6 '08 #2
"Michael Fesser" wrote...
: Works here (5.2.6), but the operator should be |, not ||.

I tried |, || and OR. Must be something else. Thanks. I'll dig a little
deeper and see if I can spot it.

--
Jim Carlock
You Have More Than Five Senses
http://www.associatedcontent.com/art...ve_senses.html

Oct 6 '08 #3
"Michael Fesser" wrote...
: Works here (5.2.6), but the operator should be |, not ||.

What about inside a class...

<?php
define('P_START_YES', 1, FALSE);
define('P_START_NO', 0, FALSE);
define('P_END_YES', 2, FALSE);
define('P_END_NO', 0, FALSE);
define('APPEND_NL', 4, FALSE);

class cMenus {

private $aMenus = array(
array(0, 'http://www.example.com/', 'Example 001', P_START_YES | P_END_YES | APPEND_NL),
array(1, 'http://www.example.net/', 'Example 002', P_START_YES | P_END_YES | APPEND_NL)
);

}
?>

I must be overlooking something big time, if that works.

--
Jim Carlock
You Have More Than Five Senses
http://www.associatedcontent.com/art...ve_senses.html
Oct 6 '08 #4
Jim Carlock wrote:
"Michael Fesser" wrote...
: Works here (5.2.6), but the operator should be |, not ||.

What about inside a class...

<?php
define('P_START_YES', 1, FALSE);
define('P_START_NO', 0, FALSE);
define('P_END_YES', 2, FALSE);
define('P_END_NO', 0, FALSE);
define('APPEND_NL', 4, FALSE);

class cMenus {

private $aMenus = array(
array(0, 'http://www.example.com/', 'Example 001', P_START_YES | P_END_YES | APPEND_NL),
array(1, 'http://www.example.net/', 'Example 002', P_START_YES | P_END_YES | APPEND_NL)
);

}
?>

I must be overlooking something big time, if that works.
This is completely different than your first post. Initializing
variables in a class must use constants - no variables or operators are
allowed.

If you need this, put it in the constructor.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 7 '08 #5
"Jerry Stuckle" wrote...
: This is completely different than your first post. Initializing variables
: in a class must use constants - no variables or operators are allowed.
:
: If you need this, put it in the constructor.
:

Thanks. I kept thinking I left out a parenthesis or quotation mark. That
fixed it. The error message threw me off.

[06-Oct-2008 19:36:30] PHP Parse error: syntax error, unexpected '|', expecting ')'

Yeah, I did not realize the class made a difference like that. I thrive
off the procedural speed and the low memory use/requirements.

Thanks, Jerry. Thanks, Micha.

--
Jim Carlock
You Have More Than Five Senses
http://www.associatedcontent.com/art...ve_senses.html
Ralph Nader Is Running! http://www.votenader.org/

Oct 7 '08 #6

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

Similar topics

21
3897
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
4
2177
by: Bret Pehrson | last post by:
I just stumbled across the following problem: //.h class Masses { static double mass1; static double mass2; static double mass3; };
11
5015
by: Greenhorn | last post by:
Hi, K&R says that "floating point constants contain a decimal point (123.4) or an exponent (1e-2) or both; their type is double; unless suffixed. The suffixes f or F indicate a float constant; l...
2
1803
by: JJ Feminella | last post by:
This statement is legal C#: public const string day = "Sunday"; but this statement is not: public const string days = new string { "Sun", "Mon", "Tue" }; The C# Programmer's Reference...
21
4153
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
1
3584
by: joesfer | last post by:
I'm trying to develop a graphical user interface for a renderer i've got written in an unmanaged C++ DLL with C#. During the rendering process, several images are sent to a delegate as float*...
3
5830
by: Steve Folly | last post by:
Hi, I had a problem in my code recently which turned out to be the 'the "static initialization order fiasco"' problem (<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>) The FAQ...
1
3088
by: chiefychf | last post by:
I'm working on a school project and I am having a few issues... The program calls for three arrays a,b,c that have to be sorted, then compared to even or odd and stored in arrays d & e, then merge...
29
35380
weaknessforcats
by: weaknessforcats | last post by:
Arrays Revealed Introduction Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with arrays and array syntax but is not clear on a )exactly how...
0
7252
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
7153
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
7432
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...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
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
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.