You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stephen Brooks <sb...@stephenbrooks.org> on 2002/10/25 17:57:57 UTC

[users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

I've been playing with my WAP phone and my server...  A standard .wml page
works fine on my server, requiring no additional configuration to get the
MIME type correct.  I had already made HTML files parse as PHP with the
following

AddType application/x-httpd-php .html

...so I thought why not make my WAP pages be server generated with

AddType application/x-httpd-php .wml

...but this causes my installation of PHP to panic when it sees the <?xml
version="1.0" ?> tag, thinking it's PHP code.  I tried replacing this with
the obvious <?php echo '<?xml version="1.0" ?>'; ?> thing, but my phone
would not have it, and a web WAP browser simulator said the content type was
now not correct.  IE displayed the page's source as exactly what should be
transmitted for the XML implementation of WAP, so it must now just be a
question of setting the content type to text/vnd.wap.wml .  I tried a second
AddType statement

AddType application/x-httpd-php .wml
AddType text/vnd.wap.wml .wml

...but now PHP parsing appears to have been turned off.  I also tried adding
an <HTTP content-type="text/vnd.wap.wml" /> tag but that also did not work.

I suspect one of AddOutputFilter or AddHandler together with the 2nd AddType
will do what I want (i.e. run PHP on the file before sending), but the
Apache documentation itself does not give me the Filter/Handler names that
correspond to PHP and I'm having a tough time finding this out from the PHP
site.

    -Stephen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Jacob Coby <jc...@listingbook.com>.
> That's excellent - it works!  I thought PHP acted by changing just the
> content string while Apache still handles the sending, so I didn't expect
it
> could change a header like that.  Evidently it's a bit more integrated
than
> I thought.

To apache, it is just echoing a file back to the browser.  Because that file
was filtered through php first doesn't really matter.  If you understand *ix
pipes, it is like: 'cat somefile.php | php | apache | browser' whereas
serving a normal .html file would be like 'cat somefile.html | addmimetype |
apache | browser'  not the best analogy, but it is the best I can think of
:)

You can actually trick php-parsed files to act like any sort of document,
apache is just the messenger.

-Jacob


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Stephen Brooks <sb...@stephenbrooks.org>.
--[ok, try changing the header from within the php script:
header("Content-type: text/vnd.wap.wml"); This will replace the standard
text/html MIME type that php echos.]--

That's excellent - it works!  I thought PHP acted by changing just the
content string while Apache still handles the sending, so I didn't expect it
could change a header like that.  Evidently it's a bit more integrated than
I thought.

--[Seems that php ignores the <? and ?> tags if they are in the string.
Good call, I was assuming that they were special characters since they are
picked up from within comments.]--

I think <? will be picked up at any position in the "raw text" because PHP's
tokeniser is turned off there.  But from then on it'll start walking through
in terms of language elements, so a string gets treated as one entity and ?>
only detected after a statement has finished.

    -Stephen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Jacob Coby <jc...@listingbook.com>.
> Good idea, but this had the same effect as <?php echo "<?xml
> everything?>\n"; ?> did.  I think <? and ?> inside quotes inside PHP are
> safe anyway.  The real problem is currently that the output is being sent
as
> the wrong MIME type (probably text/html or something to do with PHP
instead
> of text/vnd.wap.wml).

Ahh now I see!  You caught me, I wasn't paying attention at the beginning of
the thread :)

ok, try changing the header from within the php script:

header("Content-type: text/vnd.wap.wml");

This will replace the standard text/html MIME type that php echos.

Seems that php ignores the <? and ?> tags if they are in the string.  Good
call, I was assuming that they were special characters since they are picked
up from within comments.

-Jacob


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Stephen Brooks <sb...@stephenbrooks.org>.
--[Another option is to change the <?xml tags into print "<"."?xml";  <stuff
here> print "?".">"; That would prevent php from seeing the <?xml ?> tags,
but still echo them to the wap device.]--

Good idea, but this had the same effect as <?php echo "<?xml
everything?>\n"; ?> did.  I think <? and ?> inside quotes inside PHP are
safe anyway.  The real problem is currently that the output is being sent as
the wrong MIME type (probably text/html or something to do with PHP instead
of text/vnd.wap.wml).

    -Stephen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Jacob Coby <jc...@listingbook.com>.
> --[you can configure php to only parse the stuff in <?php ?> tags, leaving
> the <?xml ?> tags alone.]--
>
> I'd like to do that, but my server is a shared-hosting one run by Infopop.
> I can modify .htaccess files but I'm not so sure I can edit the global
> settings for things like PHP, although I will look in the file-browser to
> see what's there.

Another option is to change the <?xml tags into print "<"."?xml";  <stuff
here> print "?".">"; That would prevent php from seeing the <?xml ?> tags,
but still echo them to the wap device.

-Jacob


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Stephen Brooks <sb...@stephenbrooks.org>.
--[you can configure php to only parse the stuff in <?php ?> tags, leaving
the <?xml ?> tags alone.]--

I'd like to do that, but my server is a shared-hosting one run by Infopop.
I can modify .htaccess files but I'm not so sure I can edit the global
settings for things like PHP, although I will look in the file-browser to
see what's there.

    -Stephen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a multi-technology question...)

Posted by Jacob Coby <jc...@listingbook.com>.
you can configure php to only parse the stuff in <?php ?> tags, leaving the
<?xmp ?> tags alone.

----- Original Message -----
From: "Stephen Brooks" <sb...@stephenbrooks.org>
To: <us...@httpd.apache.org>
Sent: Friday, October 25, 2002 11:57 AM
Subject: [users@httpd] PHP vs. WAP vs. XML vs. MIME types (a
multi-technology question...)


> I've been playing with my WAP phone and my server...  A standard .wml page
> works fine on my server, requiring no additional configuration to get the
> MIME type correct.  I had already made HTML files parse as PHP with the
> following
>
> AddType application/x-httpd-php .html
>
> ...so I thought why not make my WAP pages be server generated with
>
> AddType application/x-httpd-php .wml
>
> ...but this causes my installation of PHP to panic when it sees the <?xml
> version="1.0" ?> tag, thinking it's PHP code.  I tried replacing this with
> the obvious <?php echo '<?xml version="1.0" ?>'; ?> thing, but my phone
> would not have it, and a web WAP browser simulator said the content type
was
> now not correct.  IE displayed the page's source as exactly what should be
> transmitted for the XML implementation of WAP, so it must now just be a
> question of setting the content type to text/vnd.wap.wml .  I tried a
second
> AddType statement
>
> AddType application/x-httpd-php .wml
> AddType text/vnd.wap.wml .wml
>
> ...but now PHP parsing appears to have been turned off.  I also tried
adding
> an <HTTP content-type="text/vnd.wap.wml" /> tag but that also did not
work.
>
> I suspect one of AddOutputFilter or AddHandler together with the 2nd
AddType
> will do what I want (i.e. run PHP on the file before sending), but the
> Apache documentation itself does not give me the Filter/Handler names that
> correspond to PHP and I'm having a tough time finding this out from the
PHP
> site.
>
>     -Stephen
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org