|
Posted by Jerry Stuckle on 11/16/74 11:44
Mike Schumann wrote:
> Why is the comma at the end of the line any different than the lines before
> it, which parsed just fine?
>
> Mike Schumann
>
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:gsadnSYbcNT31KvZnZ2dnUVZ_sSdnZ2d@comcast.com...
>
>>Mike Schumann wrote:
>>
>>>I have the following PHP code:
>>>
>>><?php
>>> class zen_categories_ul_generator {
>>> var $root_category_id = 0,
>>> $max_level = 6,
>>> $data = array(),
>>> $root_start_string = '',
>>> $root_end_string = '',
>>> $parent_start_string = '',
>>> $parent_end_string = '',
>>>
>>> $child_start_string = '<li%s>',
>>> $child_end_string = '</li>'."\n",
>>>
>>> $spacer_string = '',
>>> $spacer_multiplier = 1;
>>>
>>>etc..........
>>>
>>>I am getting a parse error in this line:
>>>
>>> $child_end_string = '</li>'."\n",
>>>
>>>PHP doesn't like the period character.
>>>
>>>I am running PHP Ver 4.4.2
>>>
>>>Does anyone have any ideas what is going on?
>>>
>>>Thanks,
>>
>>The period is fine. But the comma at the end isn't.
>>
>>If you really do have a semicolon at the end, look for mismatched single
>>or double quotes on a previous line.
>>
>>
Your problem is that the period has a higher precedence than the comma.
Therefore it tries to end the variable definition at the period, overriding the
comma.
I don't like stringing a lot of variables on multiple lines like this - and this
is one of the reasons why (another is just style). Define them as:
var $root_category_id = 0;
var $max_level = 6;
var $data = array();
var $root_start_string = '';
var $root_end_string = '';
var $parent_start_string = '';
var $parent_end_string = '';
var $child_start_string = '<li%s>';
var $child_end_string = '</li>'."\n";
var $spacer_string = '';
var $spacer_multiplier = 1;
and your problem goes away.
You might also get by with:
$child_end_string = ('</li>'."\n"),
but I haven't tried it.
(P.S. Please don't top post).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|