Table of contents ▼▲
in cls_xml.php the php trailer ?> is missing;
It is not a requirement anymore to have a trailing ?> in php scripts. There is an arguement for putting it in for syntactical completeness. By leaving it out, whitespace is not passed to the browser which can result in header errors...
various decline ! Symbols are placed wrong;
- if{if{if{command}}} can be replaced by if if if command
cls_xml.php currently looks like this:
..
if ($aXML) {
if (array_key_exists('wiki:wiki', $aXML)) {
if (array_key_exists('attrib', $aXML['wiki:wiki'][0])) {
if (array_key_exists('xmlver', $aXML['wiki:wiki'][0]['attrib'])) {
if ($aXML['wiki:wiki'][0]['attrib']['xmlver']!=$this->env['xmlver']) {
unset($aXML['wiki:wiki'][0]['wiki:diff']);
}
}
}
}
}
return $aXML;
}
and could look like this:
..
if ($aXML)
if (array_key_exists('wiki:wiki', $aXML))
if (array_key_exists('attrib', $aXML['wiki:wiki'][0]))
if (array_key_exists('xmlver', $aXML['wiki:wiki'][0]['attrib']))
if ($aXML['wiki:wiki'][0]['attrib']['xmlver'] != $this->env['xmlver'])
unset($aXML['wiki:wiki'][0]['wiki:diff']);
return $aXML;
} //function XML2array($file)
another example:
foreach ( $ltree as $key ) {
$lnode = &$lnode[$key];
}
should be
foreach ($ltree as $key)
$lnode = &$lnode[$key];
It's functionally the same but saves some microseconds when PHP executes an if, foreach or while routine. Also it helps keeping a good overview about the source code.
The decline symbols often look like this:
if (! is_file($file)) {
#API::Msg("xml001", $lfile);
return null;
}
It works, too, but the better way looks like this:
if (!is_file($file))
return null;
dantro