0

Possible Duplicate:
Reference - What does this symbol mean in PHP?

I am try somewhat unsuccessfully to run a test script for the PHP-Nemid. I am trying to work my way through the code, but have become a little lost when it gets to the render function, which makes use of the file "nemid.tpl.php". When I run the script the template file is literally written to the screen, in the sense that rather then PHP filling in the relevant template variables, it instead just writes the literal PHP code. in other words <?= $some_var_value appears just as that in the rendered page's source code.

Another thing I don't understand is what is the meaning of the <?= in the template file. This is not a PHP construct I am familiar with. At first I thought I should change <?= $some_var to <? print $some_var, but in this case it still prints the literal PHP code to the page.

Would be grateful if someone could offer me some insight into what is going on here.

Template file (nemid.tpl.php)

<html>
<body>
        <form id="signedForm" name="signedForm" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
                <div id="applet">
<!-- div ID used for overlay / modal-box -->
                    <applet name="DANID_DIGITAL_SIGNATUR" tabindex="1" archive="<?= $ServerUrlPrefix ?>/bootapplet/1234567" code="dk.pbs.applet.bootstrap.BootApplet" width="200" height="250" mayscript="mayscript" style="visibility: visible; ">
                        <param name="ServerUrlPrefix" value="<?= $ServerUrlPrefix ?>"> 
                        <param name="ZIP_BASE_URL" value="<?= $ZIP_BASE_URL ?>">
                        <param name="ZIP_FILE_ALIAS" value="<?= $ZIP_FILE_ALIAS ?>">
                        <param name="log_level" value="<?= $log_level ?>"> 
                        <param name="paramcert" value="<?= $paramcert ?>">
                        <param name="signproperties" value="<?= $signproperties ?>"> 
                        <param name="paramsdigest" value="<?= $paramsdigest ?>"> 
                        <param name="signeddigest" value="<?= $signeddigest ?>"> 
                        <param name="MAYSCRIPT" value="<?= $MAYSCRIPT ?>"> 
                    </applet>
                </div>
            <input type="hidden" name="signature">
            <input type="hidden" name="result"> 
        </form>
<script type="text/javascript">
    function onLogonOk(signature) {
        document.signedForm.signature.value=signature;
        document.signedForm.result.value='ok';
        document.signedForm.submit();
    }
    function onLogonCancel() {
        document.signedForm.result.value='cancel';
        document.signedForm.submit();
    }
    function onLogonError(emsg) {
        document.signedForm.result.value=emsg;
        document.signedForm.submit();
    }
</script> 
</body>
</html>

Render function

I have tested the contents of $vars in the below function and can confirm that the extracted variables required by the template are present.

function render($template, $vars = array())
{
    extract($vars);
    ob_start();
    include('../templates/' . $template . '.tpl.php');
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Community
  • 1
  • 1
Benjen
  • 2,835
  • 5
  • 28
  • 42

3 Answers3

4

<?= is a short open tag for echo.

<?='Hello world'?>

Would output Hello world

And to answer why it's not parsing, what's the filename? Do you have PHP installed and configured to work with your Apache/Nginx/other server?

Another thing to note is that the template you have utilizes PHP_SELF

PHP_SELF actually opens up many vulnerabilities and is not recommended to be used. You could use the alternative:

basename(__FILE__);
David Harris
  • 2,697
  • 15
  • 27
1
  <?=

is php shorthand for

  <?php echo 
Alain Tiemblo
  • 36,099
  • 17
  • 121
  • 153
Laurence
  • 58,936
  • 21
  • 171
  • 212
0
<?=

is used as a shorthand, a lot by template makers as they are using HTML for most of the file and just printing out variables in PHP as needed.

My server has that turned on but it can be turned off or not used in older versions.

donlaur
  • 1,269
  • 1
  • 12
  • 21