PHP script

I have just begun trying Blocs and may be I have missed something.

Could you please advise if I can add PHP script to an elements, like a button?

Thanks for advising,

You can input php via the HTML widget, take care to set the page suffix to php via the page settings.

Thanks for advising.

I have set the page suffix to php but it does not work.

In the editor, shall I just type the PHP code, for instance:
echo “test”;
or shall I write:

<?php echo "test; ?>

Thanks for helping,

Write the php as you normally would wrapped in <php blocs currently doesn’t preview php in app, you will need to export and run a local server for that.

Thanks again.
I have typed:

<php echo="" “-------=”" contatore="" consumi="" -------";="">

Is that correct?

However when I preview, I can not see anything printed. Is because I need to change the color of the text written?

Thanks for your patience,

How are you previewing? Blocs doesntvsupport php previewing.

I do not see anything, as nothing were written. For sure I am typing wrong.

By way of example, could you please show me a couple of php instructions as you would input them in the code editor, so that I will understand?

Thanks a lot,

How are you texting your php code, are you running your exported blocs project on a server that supports php?

Yes, the server works perfectly, all my index.php have work there for years.

For sure it is a matter of typing wrong in the box.
I will give you an example. You need to show in a website the information given by the following php instruction:

<?php echo "test; ?>

What would you type in the box?

By the way, I have copied and pasted above text.


So when you export from Blocs and run the Blocs created php files on your server, do they work?

All the scripts that I have hand written work in my Nginx automation server.

The simple script <?php echo "test; ?> written in Blocs does not show anything.

Again, if you give me a php working example, I will type and understand the syntax, otherwise we keep on discussing.


Are you aware of the typo? you are missing a closing ".

Your code should be:

<?php echo "test"; ?>

That works for me.


It works now, thank! Too quickly typing

1 Like

i have a question: sometime if i’m using php code in html widget, this code is multi-lined, chars “<?” are replaced by html characters!!! This work only if code is inline.

Could you share an example snippet that breaks please ?