Rendering HTML in PHP: HTML is the basis for creating any page and in many situations it is necessary to render it at runtime. This means that at any given time it needs to be written the extent to which the code is running.

To make it clearer that kind of situation, an example will be shown in sequence in HTML:

<?php

function returnlink(){

return ‘<a href=www.scriptcase.com.br >Scriptcase</a>’

}

?>

<html>

<body>

<div><?php returnsLinks()  ?></div>

</body>

</html>

In the example, a link is rendered inside a div from a PHP method. In a simple way, it is possible to understand the working logic in more complex situations. A link can be rendered, as well as any other elements such as a selection list or button.

Now, using logic, a second example will be presented:

<?php

function returnslist ($reg){

$lst = ‘<ul>’;

for ($i = 1; $i <= $reg; $i++)

{

$lst = $lst .'<li>’.$i.'</li>’;

}

$lst = $lst.'</ul>’;

                return $lst;

}

?>

<html>

<body>

<div><?php returnsList (10)  ?></div>

</body>

</html>

In the example, a sequential list according to the reported number of records in the method call is rendered. The exit code of our example will be:

<ul>

<li>1</li>

<li>2</li>

<li>3</li>

<li>4</li>

<li>5</li>

<li>6</li>

<li>7</li>

<li>8</li>

<li>9</li>

<li>10</li>

</ul>

This type of logic can be used, for example, to traverse an array with data loaded from a query in the database.

Check out more content on our blog!
Learn all about Scriptcase.

Create everything a system needs

Develop web applications in a few easy steps, including data queries, summaries, graphs, and pivot tables, editable forms and grids, calendars with Google Calendar integration, dynamic menus, PDF and XLS reports, dashboards, security module including user management and social login.

Personalize your applications with ready-made and editable themes, in addition to fonts with Google Fonts, Vector Icon Library with FontAwesome and dynamic notifications with SweetAlert2. Run Example →

Collaborative development: teams of all sizes have already turned millions of ideas into real applications in more than 50 languages.

By ,

July 8, 2015

a

You might also like…

5 reasons you can’t miss a Black Friday Scriptcase!

This November we bring you the biggest and most important discounts of the year! And do you know wh...

Taking a look at Scriptcase version 9.7

After the big Scriptcase 9.7 presentation event, we have a new version of Scriptcase for download, ...

October Newsletter

Follow the latest news for the month of October! Webinars, blog posts, videos, and more. WEB...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.