Nhúng template, và sử dụng object trong PHP

File template: template.tpl.php

[syntax type=”php”]<?php
return “<!DOCTYPE html>
<meta http-equiv=’Content-Type’ content=’text/html;charset=utf-8′ />

File Index: index.php

[syntax type=”php”]<?php
error_reporting( E_ALL );
ini_set( “display_errors”, 1 );
$myName = “Tran Ky Phat”;
$pageData = new stdClass(); // Khởi tạo object
$pageData->title = “Hello Title”; //Modify thuộc tính của object
$pageData->content = “Hello Content”;
$page = include_once “template.tpl.php”; // inlcude template

echo $page;
echo “<h1>Welcome to my website.$myName</h1>”;


Hello World PHP

Category: Uncategorized

Join the discussion

Your email address will not be published. Required fields are marked *