Donnerstag, 6. März 2008

Triple Quotation Mark

I would like to see a new feature which is useful in almost every programming language in which you like to generate HTML and JavaScript code. Beside the single quotation mark ' and the double quotation mark " a new triple quotation mark ''' would be very handy.

Why? See for example this php code:

echo '';

This common statement generates a HTML submit button with an onclick JavaScript event. By using the ' and " quotation marks it was already avoided to escape the quotation marks for the HTML code, but for the JavaScript it is still necessary to escape the alert message string with \'

Some people might say you can also use the PHP operator <? ?> to write the HTML directly without using the echo command, but if you work with objects it is often necessary to place the HTML code in a string.

In practice we have much more complex code lines as the simple example above, so it would be easier to read with a triple quotation mark:

echo ''''Done''');" type="submit">';

Just a funny idea of mine :)

Like it? Share it! Flattr this

1 Kommentar:

Alex hat gesagt…

so was in der Art gibt es eigentlich schon .. mit der heredoc Syntax. Da kann man sich jedes Mal neu definieren, was das Textende definieren soll:

http://de.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc