How to create HTML page with PHP

Asked

Viewed 180 times

0

I don’t have much knowledge and I don’t know if the way I’m doing it is correct or has any negative points. There’s some better option for me to do?

<?php
$ht = '<div class="panel panel-headline">';
$ht .= '<div class="panel-heading">';
$ht .= '<form id="searchthis" method="get">';
$ht .= '<input id="namanyay-search-box" name="search" size="40" type="text" placeholder="Search"/>';
$ht .= '<button id="namanyay-search-btn" type="submit" class="btn btn-primary"><i class="fa fa-search" aria-hidden="true"></i></button>';
$ht .= '</form>';
$ht .= '<h3 class="panel-title">Manage OneDrive Videos</h3>';
$ht .= '</div>';
$ht .= '<div class="panel-body" style="overflow: auto;">';
$ht .= '<table class="table table-hover">';

echo $ht;
?>

1 answer

3

In general there is no problem in doing so, but the staff usually use the system of template, I mean, you put HTML first and you put PHP code in the necessary gaps. What is not the case with this code, that is, this example should be a static HTML page that doesn’t even pass through the PHP processor, would be absurdly faster like this.

Pretty basic example of how to do it:

<html>
    <head>
        <title>PHP Test</title>
    </head>
    <body>
        <p><?php echo "1 + 1 é " . (1 + 1); ?></p>
    </body>
</html>

Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.

Of course, the example is silly and so would not need to go through PHP, but gives an idea of how is more common. What you would probably do is a page that would receive the value sent by your example and treat giving a final result that would be delivered to the browser.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.