PHP script


#1

Hello,
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,
dan


#2

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


#3

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,


#4

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.


#5

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,


#6

How are you previewing? Blocs doesntvsupport php previewing.


#7

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,
daniele


#8

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


#9

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.

Thanks


#10

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


#11

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.

Thanks


#12

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

Your code should be:

<?php echo "test"; ?>

That works for me.


#13

It works now, thank! Too quickly typing


#14

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.


#15

Could you share an example snippet that breaks please ?