Page 1 of 1

php with hypertext

Posted: 08 Aug 2006 23:37
by ufku
i tried to combine php syntax with html syntax for html containing php files. the result is just a broken head.
i added php functions and keywords to html syntax. it didnt help. i added a <? ?> block with higlight keywords. it didnt help.
i tried the reverse in which i added tags to php syntax. again i got nothing.

if the tags are in action, the rest are considered as plain text. there is no way to higlight keywords in that text. i tried defining php blocks(BlockAsString=no, BlockOnLine=No, BlockStart=<?, BlockEnd=?>) but it didnt work.

i think if the engine considered "<?php" as a tag, there would be a situation like the javascript tag in which the keywords are higlighted. am i wrong?

Posted: 09 Aug 2006 10:25
by Rickard Johansson
Maybe it's better to use multiple highlighters. Maybe a line in the Html syntax file that loads the PHP syntax as well. Whenever a <?php is encountered the PHP syntax kicks in, and when the > is encountered the HTML syntax is used again. Just a thought.

Posted: 09 Aug 2006 10:44
by jerry1970
Rickard Johansson wrote:Maybe it's better to use multiple highlighters. Maybe a line in the Html syntax file that loads the PHP syntax as well. Whenever a <?php is encountered the PHP syntax kicks in, and when the > is encountered the HTML syntax is used again. Just a thought.
Sounds great! But don't forget that the HTML syntax should be taken up where it was left off. For example:

Code: Select all

<p>Hello, <b><?php echo $name; ?></b>!
Or maybe a better example:

Code: Select all

<font size="<?php echo $fontsize; ?>">Hello!</font>
EditPlus has these syntax file directives:
#HTML_EMBEDDED=y
#SCRIPT_BEGIN=<?
#SCRIPT_END=?>

Jerry

Posted: 09 Aug 2006 11:03
by Rickard Johansson
I'm not sure about the PHP highlighting inside a string. I think a string should be highlighted as a string. Anything else just seems wrong, some how.

Posted: 09 Aug 2006 11:18
by jerry1970
Rickard Johansson wrote:I'm not sure about the PHP highlighting inside a string. I think a string should be highlighted as a string. Anything else just seems wrong, some how.
When I'm programming PHP, I am *very* glad to see the PHP code syntax coloured as PHP code, and not as an HTML string. PHP is embedded into HTML - both should be separate entities and thus have their own syntax colouring.

Jerry

Posted: 09 Aug 2006 12:15
by Rickard Johansson
PHP is embedded into HTML - both should be separate entities and thus have their own syntax colouring.
Well, if you put it that way it accually sound reasonable. :)

Posted: 09 Aug 2006 12:18
by jerry1970
Rickard Johansson wrote:
PHP is embedded into HTML - both should be separate entities and thus have their own syntax colouring.
Well, if you put it that way it accually sound reasonable. :)
Hey, I am a programmer too, I am supposed to be able to make things sound logical and reasonable! :D