Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 6th, 2008, 10:55 PM
Jim Carlock
Guest
 
Posts: n/a
Default 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

  #2  
Old October 6th, 2008, 11:05 PM
Michael Fesser
Guest
 
Posts: n/a
Default Re: arrays, constants, booleans, arithmetic values

..oO(Jim Carlock)
Quote:
>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
  #3  
Old October 6th, 2008, 11:55 PM
Jim Carlock
Guest
 
Posts: n/a
Default Re: arrays, constants, booleans, arithmetic values

"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

  #4  
Old October 7th, 2008, 12:05 AM
Jim Carlock
Guest
 
Posts: n/a
Default Re: arrays, constants, booleans, arithmetic values

"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


  #5  
Old October 7th, 2008, 02:15 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: arrays, constants, booleans, arithmetic values

Jim Carlock wrote:
Quote:
"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.
jstucklex@attglobal.net
==================

  #6  
Old October 7th, 2008, 02:55 AM
Jim Carlock
Guest
 
Posts: n/a
Default Re: arrays, constants, booleans, arithmetic values

"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/

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles