You are here:  » How to create an include file (ex: inc_xml.php)


How to create an include file (ex: inc_xml.php)

Submitted by umbro909 on Tue, 2007-03-20 16:12 in

Hi David,

I need your help (again ;-) )

Can you tell me how can I create an inc_xml.php, cause when I want to include the php script into my php file (running under zend optimizer) the following error message displays :

header("Content-Type: text/html;charset=utf-8"); require("MagicParser.php"); function myProductRecordHandler($record) { print "
".$record["PRODUCT-NAME"]."
"; print ""; print "
".$record["PRODUCT/PRODUCTDESCRIPTION-LONGDESC"]."
"; } // first parse to extract the top level product information $url = "http://localhost/xml/488140.xml"; MagicParser_parse($url,"myProductRecordHandler","xml|ICECAT-INTERFACE/"); print "
Features
"; function myFeatureRecordHandler($record) { print "
"; print $record["FEATURE/NAME-VALUE"].": "; print $record["PRODUCTFEATURE-VALUE"]." "; print $record["FEATURE/MEASURE-SIGN"]; print "
"; } // second parse to extract the feature list MagicParser_parse($url,"myFeatureRecordHandler","xml|ICECAT-INTERFACE/PRODUCT/PRODUCTFEATURE/");

So can you help me please?

Thanks.
Sabri

Submitted by support on Tue, 2007-03-20 16:17

Hello Sabri,

I'm not quite sure where the problem lies here. Have you already created an include file, and the error occurs when you call it? A basic include can be done as follows:

inc_xml.php

<?php
  
// code to be included here
?>

And then in your main script:

<?php
  
require("inc_xml.php");
?>

Apologies if I have misunderstood - if you can provide any more info I'll try and help out further...

Cheers,
David.

Submitted by umbro909 on Tue, 2007-03-20 16:50

Hi David,

my problem is that I need to create a inc_xml.TPL to implement your script in my system, and not a inc_xml.php.

In fact, when I create a inc_xml.php, my system doesn't accept the

<?php
 
...  
?>
because my parent page script (in php) already has
this tags! That's why it doesn't work.

Have you some idea to help me ? :-(

Submitted by support on Wed, 2007-03-21 10:27

Hi,

I'm afraid I'm still not totally sure that I understand the issue here. There shouldn't be any problem with the PHP tags because when you include() or require() another file the processor drops out of PHP mode and needs to see the tags again. However, have you tried removing them in this case? What code are you using to include the file in your main file?

Cheers,
David.

Submitted by umbro909 on Wed, 2007-03-21 15:16

Hi dear David.

I'm a stupid man :-)!! It's my fault...
I was using: [{ include file="inc_xml.php" }]
in the place of: [{ include_php file="icecat.php" }]

Now, everything works fine.

Thanks again.
;-)