473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xml pages with <? in it are choking my PHP code

Most of our designers prefer to work in Dreamweaver. They now, this
month, want to produce templates that are valid XHTML 1.0. In
Dreamweaver, this is as simple as clicking a button.

Up till now, we've been storing the templates in a database, bring
them out when a webpage needs to be rendered, and hitting the page
with eval(). The eval() function goes through and spits out the pure
HTML and takes any PHP commands it finds and executes. All was well
and good.

Problems have arisen now that the designers want their code to be
XHTML valid. This means having, at the top of the page, a declaration
that looks like:

<?xml // more stuff here.

Of course this is giving parse errors. The PHP parser sees the "<?"
and assumes what follows is PHP, but can find a command called xml.
Not sure how to solve this one. Does anyone have some creative ideas?
Some of the PHP commands embedded in the templates have echo and print
statements, so there is no way to remove and then later replace the
XML declaration.
Jul 17 '05 #1
6 2111
> Of course this is giving parse errors. The PHP parser sees the
"<?" and assumes what follows is PHP, but can find a command
called xml. Not sure how to solve this one. Does anyone have some
creative ideas? Some of the PHP commands embedded in the
templates have echo and print statements, so there is no way to
remove and then later replace the XML declaration.


You can fix this by editing php.ini to allow only <?php
tags to trigger php : set short_open_tags to off.
--
SeeSchloß - http://gpu.sourceforge.net

Jul 17 '05 #2


Most of our designers prefer to work in Dreamweaver. They now, this
month, want to produce templates that are valid XHTML 1.0. In
Dreamweaver, this is as simple as clicking a button.
Glad to hear your designers are taking such a worthwhile step.

Problems have arisen now that the designers want their code to be XHTML
valid. This means having, at the top of the page, a declaration that
looks like:

<?xml // more stuff here.


Bear in mind that the <?xml declaration isn't actually required for XHTML
validity. Just using the DOCTYPE is sufficient.
Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk

Jul 17 '05 #3
lawrence wrote:
Some of the PHP commands embedded in the templates have echo and print
statements, so there is no way to remove and then later replace the
XML declaration.


Sure there is, use the output buffering to capture everything first.

ob_start();
// all your stuff goes here

Then when you want to display it all:
$x=ob_get_contents();
ob_end_clean();

// echo out the <?xml tag and content
echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n",$x;

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #4
Just

<?php
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
?>

do the job

"lawrence" <lk******@geocities.com> a écrit dans le message de
news:da**************************@posting.google.c om...
Most of our designers prefer to work in Dreamweaver. They now, this
month, want to produce templates that are valid XHTML 1.0. In
Dreamweaver, this is as simple as clicking a button.

Up till now, we've been storing the templates in a database, bring
them out when a webpage needs to be rendered, and hitting the page
with eval(). The eval() function goes through and spits out the pure
HTML and takes any PHP commands it finds and executes. All was well
and good.

Problems have arisen now that the designers want their code to be
XHTML valid. This means having, at the top of the page, a declaration
that looks like:

<?xml // more stuff here.

Of course this is giving parse errors. The PHP parser sees the "<?"
and assumes what follows is PHP, but can find a command called xml.
Not sure how to solve this one. Does anyone have some creative ideas?
Some of the PHP commands embedded in the templates have echo and print
statements, so there is no way to remove and then later replace the
XML declaration.

Jul 17 '05 #5

"lawrence" <lk******@geocities.com> a écrit dans le message news:
da**************************@posting.google.com...
Of course this is giving parse errors. The PHP parser sees the "<?"
and assumes what follows is PHP,


if short_open_tag is off in php.ini, only <?php is allowed to begin a php
script. It should resolve the problem.
Regards,
Philippe
Jul 17 '05 #6
Thanks for all the intelligent responses. The echo statment seems
simplest but it seems inflexible - I'd have to change the code every
time a designer wanted a different doctype declaration. I might make a
function call for the doctype and provide some forms for the
designers, but neither they nor I would like the extra work. So
adjusting the ini file sounds best.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Patrick | last post by:
I understand that with IIS5.1 on Windows XP Professional SP1, I can 1) Either set under IIS Manager-> Any specific Virtual Directory-> Configuration->Options->ASP Script timeout for all pages...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
7
by: smerf | last post by:
I am trying to write a personal spider to crawl through websites and create a highly specialized personal list of sites and pages that I may like to see based on preferences that I have supplied. ...
5
by: Nathan Sokalski | last post by:
My Web.config file contains the following section to register some of my UserControls: <pages> <controls> <add tagPrefix="NATE" tagName="Banner" src="~/Banner.ascx"/> <add tagPrefix="NATE"...
3
by: anuragpj | last post by:
i have designed a login page like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Electrical Engineering Dept...
3
by: Yash | last post by:
Hi all, I found that while we are updating our application, the application is not known to tomcat, untill it is completed. So tomcat sends 503 page as resource not found. I want to know is...
8
by: Jeigh | last post by:
I did not write this script myself and am having a bit of trouble with it, it's working fine except it's missing the first piece of data for each page. This being data for each user. For example,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.