php method chaining not backward compatible
Posted: Fri Oct 16, 2009 8:15 pm
I'm new to php so please forgive me if this is elementary... I have a Wordpress plugin that a friend wrote with php 5. The plugin won't work on the server of the site I'm working on because the host is running php 4.4 (and is NOT going to upgrade). His plugin breaks during this part of the script: (the lines of method chaining)
How would something like this have been done in php 4? I thought I could just capture the same elements in an array and call them individually to place them into the respective vars... like I said, I'm a newb to php so I could be way off in my logic and syntax. Thanks for your help.
I forgot to mention... this is the error php is generating:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in xml flash slideshow.php on line 30
line 30 in the file is : $width = $settings_doc -> getElementsByTagName("width") -> item(0) -> nodeValue;
... just in case I'm wrong about the error being from method chaining. Thanks again.
Code: Select all
function xml_flash_slideshow() {
// check if there is anything posted
if(isset($_POST['save_changes'])) {
updateXmlFile();
} else if(isset($_POST['reorder']) == 'true') {
updateXmlFile();
} else {
// load xml file
$settings_doc = new DOMDocument();
$settings_doc -> load(ABSPATH.'wp-content/plugins/xml flash slideshow/xml/settings.xml');
// get settings from file
$width = $settings_doc -> getElementsByTagName("width") -> item(0) -> nodeValue;
$height = $settings_doc -> getElementsByTagName("height") -> item(0) -> nodeValue;
$border_width = $settings_doc -> getElementsByTagName("border_width") -> item(0) -> nodeValue;
$border_radius = $settings_doc -> getElementsByTagName("border_radius") -> item(0) -> nodeValue;
$border_top_color = $settings_doc -> getElementsByTagName("border_top_color") -> item(0) -> nodeValue;
$border_btm_color = $settings_doc -> getElementsByTagName("border_btm_color") -> item(0) -> nodeValue;
$border_dropshadow = $settings_doc -> getElementsByTagName("border_dropshadow")-> item(0) -> nodeValue;
$img_dot_color = $settings_doc -> getElementsByTagName("img_dot_color") -> item(0) -> nodeValue;
$images = $settings_doc -> getElementsByTagName("image");
foreach ($images as $image) {
$paths = $image -> getElementsByTagName( "path" );
$path_obj = $paths -> item(0) -> nodeValue;
$links = $image -> getElementsByTagName( "link" );
$link_obj = $links -> item(0) -> nodeValue;
$path[] = $path_obj;
$link[] = $link_obj;
}
}
I forgot to mention... this is the error php is generating:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in xml flash slideshow.php on line 30
line 30 in the file is : $width = $settings_doc -> getElementsByTagName("width") -> item(0) -> nodeValue;
... just in case I'm wrong about the error being from method chaining. Thanks again.