Parse error: syntax error, unexpected else (T ELSE), expecting function (T FUNCTION)
Hallo,
ich habe oben genannte Fehler, komme aber in PHP nicht sooo gut zurecht. Es waren noch einige andere Fehler drin, welche ich aber schon reparieren konnte. Ich habe mit PHPDesigner 8 mir betreffende Datei angeschau und bekomme diesen Code
Betreffende Zeile ist hierbei die Zeile 55 mit dem Wort else. Ich komme nicht damit klar was hier noch falsch sein sollte. Kann mir dabei bitte jemand helfen?
LG Kepala
ich habe oben genannte Fehler, komme aber in PHP nicht sooo gut zurecht. Es waren noch einige andere Fehler drin, welche ich aber schon reparieren konnte. Ich habe mit PHPDesigner 8 mir betreffende Datei angeschau und bekomme diesen Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?php
/**
* @version $Id: select.php 20640 2011-02-10 06:26:40Z infograf768 $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Utility class for creating HTML select lists
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
abstract class JHtmlSelect
{
/**
* Default values for options. Organized by option group.
*
* @var array
*/
static protected $_optionDefaults = array(
'option' => array(
'option.attr' => null,
'option.disable' => 'disable',
'option.id' => null,
'option.key' => 'value',
'option.key.toHtml' => true,
'option.label' => null,
'option.label.toHtml' => true,
'option.text' => 'text',
'option.text.toHtml' => true,
),
);
/**
* Generates a yes/no radio list.
*
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param mixed The key that is selected
* @return string HTML for the radio list
*/
public static function booleanlist(
$name, $attribs = null, $selected = null, $yes = 'JYES', $no = 'JNO', $id = false
) {
$arr = array(
JHtml::_('select.option', '0', JText::_($no)),
JHtml::_('select.option', '1', JText::_($yes))
);
return JHtml::_('serray_merge($options, $optKey)')
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['disable'] = $disable;
}
$obj = new JObject;
$obj->$options['option.key'] = $value;
$obj->$options['option.text'] = trim($text) ? $text : $value;
/*
* If a label is provided, save it. If no label is provided and there is
* a label name, initialise to an empty string.
*/
$hasProperty = $options['option.label'] !== null;
if (isset($options['label'])) {
$labelProperty = $hasProperty ? $options['option.label'] : 'label';
$obj->$labelProperty = $options['label'];
} elseif ($hasProperty) {
$obj->$options['option.label'] = '';
}
// Set attributes only if there is a property and a value
if ($options['attr'] !== null) {
$obj->$options['option.attr'] = $options['attr'];
}
// Set disable only if it has a property and a value
if ($options['disable'] !== null) {
$obj->$options['option.disable'] = $options['disable'];
}
return $obj;
}
/**
* Generates the option tags for an HTML select list (with no select tag
* surrounding the options).
*
* @param array An array of objects, arrays, or values.
* @param mixed If a string, this is the name of the object variable for
* the option value. If null, the index of the array of objects is used. If
* an array, this is a set of options, as key/value pairs. Valid options
* are:
* <ul><li>Format options, {@see JHtml::$formatOptions}.
* </li><li>groups: Boolean. If set, looks for keys with the value
* "<optgroup>" and synthesizes groups from them. Deprecated. Defaults
* true for backwards compatibility.
* </li><li>list.select: either the value of one selected option or an array
* of selected options. Default: none.
* </li><li>list.translate: Boolean. If set, text and labels are translated via
* JText::_(). Default is false.
* </li><li>option.id: The property in each option array to use as the
* selection id attribute. Defaults to none.
* </li><li>option.key: The property in each option array to use as the
* selection value. Defaults to "value". If set to null, the index of the
* option array is used.
* </li><li>option.label: The property in each option array to use as the
* selection label attribute. Defaults to null (none).
* </li><li>option.text: The property in each option array to use as the
* displayed text. Defaults to "text". If set to null, the option array is
* assumed to be a list of displayable scalars.
* </li><li>option.attr: The property in each option array to use for
* additional selection attributes. Defaults to none.
* </li><li>option.disable: The property that will hold the disabled state.
* Defaults to "disable".
* </li><li>option.key: The property that will hold the selection value.
* Defaults to "value".
* </li><li>option.text: The property that will hold the the displayed text.
* Defaults to "text". If set to null, the option array is assumed to be a
* list of displayable scalars.
* </li></ul>
* @param string The name of the object variable for the option text.
* @param mixed The key that is selected (accepts an array or a string)
* @return string HTML for the select list
*/
public static function options(
$arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false
) {
$options = array_merge(
JHtml::$formatOptions,
self::$_optionDefaults['option'],
array(
'format.depth' => 0,
'groups' => true,
'list.select' => null,
'list.translate' => false,
)
);
if (is_array($optKey)) {
// Set default options and overwrite with anything passed in
$options = array_merge($options, $optKey);
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['list.select'] = $selected;
$options['list.translate'] = $translate;
}
$html = '';
$baseIndent = str_repeat($options['format.indent'], $options['format.depth']);
foreach ($arr as $elementKey => &$element)
{
$attr = '';
$extra = '';
$label = '';
$id = '';
if (is_array($element))
{
$key = $options['option.key'] === null
? $elementKey : $element[$options['option.key']];
$text = $element[$options['option.text']];
if (isset($element[$options['option.attr']])) {
$attr = $element[$options['option.attr']];
}
if (isset($element[$options['option.id']])) {
$id = $element[$options['option.id']];
}
if (isset($element[$options['option.label']])) {
$label = $element[$options['option.label']];
}
if (isset($element[$options['option.disable']]) && $element[$options['option.disable']]) {
$extra .= ' disabled="disabled"';
}
} elseif (is_object($element)) {
$key = $options['option.key'] === null
? $elementKey : $element->$options['option.key'];
$text = $element->$options['option.text'];
if (isset($element->$options['option.attr'])) {
$attr = $element->$options['option.attr'];
}
if (isset($element->$options['option.id'])) {
$id = $element->$options['option.id'];
}
if (isset($element->$options['option.label'])) {
$label = $element->$options['option.label'];
}
if (isset($element->$options['option.disable']) && $element->$options['option.disable']) {
$extra .= ' disabled="disabled"';
}
} else {
// This is a simple associative array
$key = $elementKey;
$text = $element;
}
/*
* The use of options that contain optgroup HTML elements was
* somewhat hacked for J1.5. J1.6 introduces the grouplist() method
* to handle this better. The old solution is retained through the
* "groups" option, which defaults true in J1.6, but should be
* deprecated at some point in the future.
*/
$key = (string) $key;
if ($options['groups'] && $key == '<OPTGROUP>') {
$html .= $baseIndent . '<optgroup label="'
. ($options['list.translate'] ? JText::_($text) : $text)
. '">' . $options['format.eol'];
$baseIndent = str_repeat($options['format.indent'], ++$options['format.depth']);
} else if ($options['groups'] && $key == '</OPTGROUP>') {
$baseIndent = str_repeat($options['format.indent'], --$options['format.depth']);
$html .= $baseIndent . '</optgroup>' . $options['format.eol'];
} else {
// if no string after hypen - take hypen out
$splitText = explode(' - ', $text, 2);
$text = $splitText;
if (isset($splitText[1])) {
$text .= ' - ' . $splitText[1];
}
if ($options['list.translate'] && !empty($label)) {
$label = JText::_($label);
}
if ($options['option.label.toHtml']) {
$label = htmlentities($label);
}
if (is_array($attr)) {
$attr = JArrayHelper::toString($attr);
} else {
$attr = trim($attr);
}
$extra = ($id ? ' id="' . $id . '"' : '')
. ($label ? ' label="' . $label . '"' : '')
. ($attr ? ' ' . $attr : '')
. $extra
;
if (is_array($options['list.select']))
{
foreach ($options['list.select'] as $val)
{
$key2 = is_object($val) ? $val->$options['option.key'] : $val;
if ($key == $key2) {
$extra .= ' selected="selected"';
break;
}
}
} elseif ((string)$key == (string)$options['list.select']) {
$extra .= ' selected="selected"';
}
if ($options['list.translate']) {
$text = JText::_($text);
}
// Generate the option, encoding as required
$html .= $baseIndent . '<option value="'
. ($options['option.key.toHtml'] ? htmlspecialchars($key, ENT_COMPAT, 'UTF-8') : $key) . '"'
. $extra . '>'
. ($options['option.text.toHtml'] ? htmlentities(html_entity_decode($text), ENT_COMPAT, 'UTF-8') : $text)
. '</option>'
. $options['format.eol']
;
}
}
return $html;
}
/**
* Generates an HTML radio list.
*
* @param array An array of objects
* @param string The value of the HTML name attribute
* @param string Additional HTML attributes for the <select> tag
* @param mixed The key that is selected
* @param string The name of the object variable for the option value
* @param string The name of the object variable for the option text
* @return string HTML for the select list
*/
public static function radiolist(
$data, $name, $attribs = null, $optKey = 'value', $optText = 'text',
$selected = null, $idtag = false, $translate = false
) {
reset($data);
$html = '';
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
$id_text = $idtag ? $idtag : $name;
foreach ($data as $ind => $obj)
{
$k = $obj->$optKey;
$t = $translate ? JText::_($obj->$optText) : $obj->$optText;
$id = (isset($obj->id) ? $obj->id : null);
$extra = '';
$extra .= $id ? ' id="' . $obj->id . '"' : '';
if (is_array($selected))
{
foreach ($selected as $val)
{
$k2 = is_object($val) ? $val->$optKey : $val;
if ($k == $k2)
{
$extra .= ' selected="selected"';
break;
}
}
} else {
$extra .= ((string)$k == (string)$selected ? ' checked="checked"' : '');
}
$html .= "\n\t" .'<input type="radio" name="' . $name . '"'
. ' id="' . $id_text . $k . '" value="' . $k .'"'
. ' ' . $extra . ' ' . $attribs . '/>'
. "\n\t" . '<label for="' . $id_text . $k . '"'
. ' id="' . $id_text . $k . '-lbl" class="radiobtn">'.$t.'</label>';
}
$html .= "\n";
return $html;
}
}
Betreffende Zeile ist hierbei die Zeile 55 mit dem Wort else. Ich komme nicht damit klar was hier noch falsch sein sollte. Kann mir dabei bitte jemand helfen?
LG Kepala
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 220876
Url: https://administrator.de/forum/parse-error-syntax-error-unexpected-else-t-else-expecting-function-t-function-220876.html
Ausgedruckt am: 15.04.2025 um 11:04 Uhr
7 Kommentare
Neuester Kommentar
Ich hab das Ding nicht geschrieben ! woher soll ich dann wissen welche Bedingung drin stehen soll:
Die hast du wahrscheinlich irgendwie rausgelöscht...hol dir die Original-Datei aus den Joomla-Repos fertig ....
Grüße Uwe
Die hast du wahrscheinlich irgendwie rausgelöscht...hol dir die Original-Datei aus den Joomla-Repos fertig ....
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
if (BEDINGUNG DIE ICH NICHT KENNE){
//MACH hier was
} else {
// Get options from the parameters
$options['option.key'] = $optKey;
$options['option.text'] = $optText;
$options['disable'] = $disable;
}
Grüße Uwe
Dann bitte noch den Beitrag auf gelöst setzen. Merci.