Short Tag

Description

This example shows using the short tag to start a C block.

A short tag <? is the same as a normal <?wc but shorter.

There are two similar open tags mainly to remain comparable to php. The second reason is that XML also starts with a <? making it hard to output the starting tag. A compile switch maybe added to disable the short version.

WebC Code

<!DOCTYPE HTML>
<html>
    <head>
        <title>Short Tag</title>
    </head>
    <body>
        <?wc wcecho("This is the normal open tag"); ?><br/>
        <? wcecho("This is the short tag"); ?><br/>
    </body>
</html>

C Code

#include "WCWebAPI.h"

void Page_ShortTag(void)
{
    wcecho("<!DOCTYPE HTML>\n"
        "<html>\n"
        "   <head>\n"
        "       <title>Short Tag</title>\n"
        "   </head>\n"
        "   <body>\n");
    wcecho("This is the normal open tag");
    wcecho("<br/>\n");
    wcecho("This is the short tag");
    wcecho("<br/>\n");
    wcecho("   </body>\n"
        "</html>\n");
}

Output

<!DOCTYPE HTML>
<html>
   <head>
       <title>Short Tag</title>
   </head>
   <body>
        This is the normal open tag<br/>
        This is the short tag<br/>
   </body>
</html>