Yii Framework Forum: Extra Line In Html Template Causes Php Parser To Fail, When Short Tags Are Disabled - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Extra Line In Html Template Causes Php Parser To Fail, When Short Tags Are Disabled Rate Topic: -----

#1 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,193
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 17 November 2012 - 09:53 AM

A case quite similar to this one, about doctype.

I wrote a non-Yii simple PHP app. It run without any problems on localhost and failed completely on webserver. I used mechanism very similar to Yii-one, for loading and parsing views stored in *.php file. I thought that problem will be there, but it turned out, that the source of the problem is first line of my template file:

<?xml version="1.0" encoding="iso-8859-2"?>

PHP's short-tags were enabled on my localhost and disabled on web server, which caused described behaviour. PHP tried to parse this line and failed. Good question, why it has passed it by, without any problems, under XAMPP+Windows, with short tags enabled. In my opinion, no matter, if they're enabled or they aren't, this line is not parsable by PHP at all.

Since I use the very same mechanism, as Yii, for loading views and layouts, I took a quick look into Yii layout file (main.php) and found out that it doesn't have this construction at first line.

So, question around app doctype. When we should use this line? Are XHTML documents still valid and go through validator without errors, if this line is removed? Is it necessary to have XHTML 1.1 Strict layout file? Finally -- why some editors are adding this line, when creating new XHTML 1.1 Strict document, while others doesn't?
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,041
  • Joined: 16-February 11
  • Location:Japan

Posted 18 November 2012 - 05:27 AM

The first 3 lines of my template are ...
<?php echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">


I once tried the following and got an error.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users