Re: Tidy HTML source?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message ----- From: "Paul Novitski" <paul@xxxxxxxxxxxxxxxxxxx>


At 11/29/2006 05:13 AM, Satyam wrote:
----- Original Message ----- From: "Paul Novitski" <paul@xxxxxxxxxxxxxxxxxxx>
What I find to be a much greater problem is the human readability of logic code when HTML is mixed throughout. Your innovation is helpful here, as you're nearly making HTML tags into PHP key words, eliminating some of the literal quoting that makes PHP+HTML so tiresome. However, even with your pre-compiler the messy quotes are still there on the attribute level.

The value of the attribute is any valid PHP expression and if they are literal strings there will be quotes, but then, you can also use heredoc if, for example, you are putting some JavaScript code into an event. If the value is a numeric value, there is no need for any quotes at all. In the end, the value of an attribute is any valid PHP expression and it follows PHP rules.


XHTML, which I would hope you would lean toward in your pursuit of XML, does require quotes on all attributes:

        XHTMLT 1.0
        4.4. Attribute values must always be quoted
        http://www.w3.org/TR/xhtml1/#h-4.4


Pht will always quote attribute values in its output, it does not require them on its input. The value of an attribute on a pht source can be anything that Php can take and somehow convert to a string, as per php rules. The output will always be quoted and escaped as required.


And, stepping back, you're perpetuating the embedding of markup with logic so that it will still take a PHP programmer to modify the markup of one of your pages. Do you not see the advantage in separating the two layers?

Yes, I do, and I would recommend using templates or similar tools to provide for separation of code and markup, but sometimes there are reasons not to do so, for example, web services.

Please explain why you think web services promote mixing markup with logic.


I didn't say it promotes but it does not require. In web services there is usually no presentation layer, there is no end user to see anything at all, then there is no need for a graphics designer separate from the application programmer. The application consuming that service might have to display the data, but the service does not.

In fact, my original idea was some sort of embedded SQL as it exists for C, but I know it does not work quite Ok, in fact, it has been there for quite some time and it doesn't catch up. SQL is such a different kind of beast that it is hard to make it compatible. SQL cursors and error handling are concepts which are hard to blend into a procedural language so I believe it is better to handle SQL through functions where it is clearly separate from the language calling them. Thus, I thought, we have three main languages here, HTML, PHP and SQL. I know PHP and SQL don't mix well, how about the other end? That's when I started to think about this pre-compiler and found it to be a pretty logical mix.

That's interesting, I don't have a problem allowing PHP & MySQL to play together. I'm pretty happy with the PHP mysql function library in which the two communicate with strings and handles; and negotiation of SQL data structures maps nicely onto PHP logic blocks. Can you give an example of where you see the discord?


Indeed, that's my point, the relationship in between php and Sql as it is, through function calls, is fine. Embedding SQL statements in the language is not. Google for "Embed Sql" and you will find samples of what it means.


I try to separate the text of my SQL queries from my PHP logic in the same way that I try to separate PHP from HTML.


Separating presentation, application and data layers by language (HTML, PHP and SQL) is the easy 'rule of thumb' way of doing it but it is not always the best. As I mentioned elsewhere, Wordpress separates each layer but not by language, the presentation layer section would still be hard on a graphic designer with no knowledge of PHP programming. The main reason to use templates is not the logic of the application but the abilities of the people and tools involved, graphic designers and editors on one side and coders on the other. That is quite a valid reason, but it might not be the prevailing one, specially, as I said, in web services, where there are no graphics involved.

Cheers

Satyam



Warm regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux