How to make PHP code write front end?

I thought of two ways:

  1. PHP code is converted directly to JS code
  2. PHP engine for front-end browsers

is it possible to achieve these two methods, and what is the difficulty?

Jan.28,2022

solution 1: feasible, equivalent to writing a HTML/JS compiler or parser, PHP is the source code, JS/HTML is the compiled code, and then directly output the compiled code to the front end. The difficulty is to implement a parser / compiler
solution 2: the front-end browser uses the engine of PHP. In theory, it is feasible, but in reality, JS already dominates the world. In doing so, there will be a lot of front-ends wanting to beat you.


the first solution is possible. You can refer to Typescript


to write html tags directly outside . Or print


and directly use php's EOF to express the front-end code and then directly echo it

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be3132-30ea0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be3132-30ea0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?