PHP - before page header and anything else

I now also came across PHP requirement. I need some PHP to be executed before anything else. So I tried to put it into the header using the options of my topic.

Unfortunately there is no setting to put the code before

<!DOCTYPE html>
<html lang="en">

    <meta charset="utf-8">

so I need to use an extern script to append the html to the PHP and then save as *.php. The PHP has to be executed so early, because only then I can modify the http headers.

So maybe this little option can be implemented.

(Of course it would be nice to be able to specify php as extension)

To change the extensions to php you can use a batch file:

cd %1
del *.php
ren *.html *.php

Use at your own risk… as you will see the third line deletes all the php files in the folder.

You can see how to set it up here:

With regards to adding php to the top you could use notepad ++ find in file feature and search for

<!DOCTYPE html>

and replace with

<?php your php here ?>
<!DOCTYPE html>

Hope this helps

Thanks for the reply. Yes, as noted I am using a script already. In my case it is:

copy downloadphp.php upload\download.php
type upload\download.html >>upload\download.php

In my form I simply load download.php and all is good. I do not even have to change the navbar.

I first copy my PHP code into the upload directory and then append the original HTML to it using >>.

My suggestion was to add an option for this. The combo box already allows
“Before Header” - it misses “Before HTML” for this use.

The same as for the additional footer text “After HTML”. It would allow a lot of extensions, especially when used globally.

I just checked out Version 6 - it is phantastic.

I checked the page settings. If I add something to “Before Content” It still is exported here:

<!DOCTYPE html>*
<html lang="en">*

    <meta charset="utf-8">*

Although I know the work around, it would be really helpful to have an option

to add scripting code such as

<?PHP before anything else is done. Thanks, Julian

Overall i would be glad if we could see in the future some php integration inside bss, it would allow to do much more than only front end, but i wouldn’t expect it, but i have hope😅

I still miss this functionality:

  • Add some text before any HTML code when exporting a page (at the first character!)
  • Add some text after all HTML code when exporting a text

Why I need this? Because when using the file as PHP script I cannot have any output before the PHP code since this automatically changes the HTTP response. Up to now I need to use a preprocessor to update the files which is not optimal to solve such an easy problem.

Ideally allow to load the before/after code from external file at the time when exporting it. That should also be very easy to do.

I would propose the following. This would give us total freedom to add code anywhere on the page.

@martin Your thoughts?