NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
HTML to PHP


Joined: 26 Nov 2018
Posts: 35
Reply with quote
Does PhpED convert HTML to PHP ?
IF it does how to?

Like here:

View user's profileFind all posts by piotrSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8097
Reply with quote
Oh, common, it's 2019. Think about AJAX and forget about printed or echoed HTML Wink

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 26 Nov 2018
Posts: 35
Reply with quote
So, it is no.
Dmitri is 2019 and your software does not have javascript 6, NuSoap is deprecated, no Angular, Vue or other important framework.
PHP frameworks intellisense are not updated.

You are not in 2019. Wake up mate.
View user's profileFind all posts by piotrSend private message


Joined: 18 Mar 2019
Posts: 9
Location: Canada
Reply with quote
Welcome to 2020.
- NuSoap is an easy fix, GitHub is loaded with updates, for example, look at github.com/pwnlabs/nusoap . Actually, personally, I winded down using SOAP 10 years ago and any project that still needs SOAP, I use the PHP SOAP extension instead.
- Frameworks support are cherry on the ice cream, but lack of them it will not stop you from working.
- lack of ES6 support, yes, this is hurting every day. I have to use an external editor to verify my syntax. Also, it makes the "Problems" tab useless as it's full of false errors.
- Another one hurting, it is the incomplete CSS3 support.

About the OP.
Using a couple of search/replace strings with regular expressions directly on your text editor of choice (PhpEd can do this) and you are done. Or even better if you are here, you must be a developer, code your own PHP script to handle the conversion.
View user's profileFind all posts by carloshSend private message


Joined: 11 Jun 2020
Posts: 1
Reply with quote
Hi!

There are 2 ways to convert your HTML page to PHP. The first one is easier, but will not work in any situation. The other one is little more complicated, but gives you better control over the conversion.

Incorporating HTML directly in the PHP file.

This is the easy way. In every PHP file the PHP code must be inserted between <?php and ?> tags. The rest will be interpreted by the web server as pure HTML. So, if you just save your HTML page with .php extension, that’s all, you have the html code “converted”. Let say the php file below is named “example.php”:

Original file (example.html)

PHP file (example.php)

<html>
<head></head>
<body>
This is HTML code
</body>
</html>

<html>
<head></head>
<body>
This is HTML code
<?php
echo “This is PHP code”;
?>
</body>
</html>

In the example above, we just put the php code (in red) inside the body. The web server will know that everything between <?php and ?> is php code and will execute it, the rest will be sent directly to the browser, because it is just static HTML. So, you can “convert” every html page to php just by renaming the file with .php extension. Unfortunately, in many cases, this is not the solution that works. Dropping in and out of parsing mode can be really slow. That’s why we may use another way to insert html code in php file.

Using PHP commands (echo, print etc.)

We can send HTML code to browser directly within PHP code. The most used way to do this is with the “echo” command. We just put the html code inside the echo command and that’s all. One simple example will look like this:

Original file (example.html)

PHP file (example.php)

<html>
<head></head>
<body>
This is HTML code
</body>
</html>

<?php
echo “<html>\n”;
echo “<head></head>\n”;
echo “<body>\n”;
echo “This is HTML code\n”;
echo “</body>\n”;
// some PHP code here …
echo “</html>\n”;
echo “\n”;
?>

Such conversion method gives you better control and more options, but it is really tedious. (That’s why I build the HTML to Script Converter) But for small-to-medium html output you should use this instead of escaping php, writing the html and going back to php. Switching many times between php/html is slow method. (However – for big html pieces, it is faster than echo or print)

echo vs. print vs. printf

Both echo() and print() are php methods for text /html/ output, but print() is slower than echo(). The reason for that is that print function will return a status indicating if it was successful or not, while echo doesn’t return anything. So, in most cases, echo is the right choice.

Printf is more powerful function, and that’s why it is slower. We should use printf() just in case that we really need its functionality.
View user's profileFind all posts by Jack HenrySend private message
HTML to PHP
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic