By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

arrays, constants, booleans, arithmetic values

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
..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

P: n/a
"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

P: n/a
"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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.