asmblah / uniter

🎉 PHP in the browser and Node.js => Docs: https://phptojs.com/
https://asmblah.github.io/uniter/
Other
446 stars 42 forks source link

HTML Tags for Uniter #47

Open phpengine opened 7 years ago

phpengine commented 7 years ago

Could something like this be possible?

<script type="text/uniter">
    echo "This is a PHP statement" ;
</script>

Cheers

asmblah commented 7 years ago

Sure - do you have an example of how you'd like to use it? I'm guessing you're after a way to differentiate between the PHP code in a standalone .php file that should be interpreted on the server by Zend's engine, and the code that should be run client side.

A bit quick'n'dirty, but did you mean something like this? https://jsfiddle.net/y4o3twze/

phpengine commented 7 years ago

This is spot on for what I was looking for. I've put an example on http://www.isophp.org.uk you can see. Cheers

niko-donskoy commented 1 year ago
<script type="php">
    test('App started!');
</script>
var scripts=document.getElementsByTagName("script");
for(var i=0; i<scripts.length; i++){
    if(scripts[i].getAttribute('type') == 'php')
    {
        script_text=scripts[i].text;
        try{
            php.execute('<?php ' + script_text);    
        }
        catch(e)
        {
            alert(e);
        }
    } 
}