導航:首頁 > 編程語言 > phphtml混編教程

phphtml混編教程

發布時間:2022-12-30 21:33:09

php 我只會用HTML混合的方法製作。這樣做可以嗎

可以,為什麼不可以?不過即時你不使用框架或模板引擎,也可以稍微考慮一下內容和表現的簡單分離。

② 怎麼把php與html嵌套在一起

PHP 和HTML混寫:
1.簡單的:
<?php
$a = 5;
$b =3;
$c = $a - $b;
echo $c;
?>
<div>HTML 代碼 </div>

-----------------------------------------------------------------------
2.用條件語句來控制HTML的輸出:
<?php
$a = 6;
$b = rand(1, 10); //產生隨機數;
if($a < $b)
{
?>
<div>HTML代碼 ,部分1</div>
<?php
}
else
{
?>
<div>HTML代碼 ,部分2</div>
<?php
}
?>

這段代碼是用PHP來控制HTML的輸出,會隨機輸出 HTML1,HTML2

③ PHP 和HTML 是怎麼結合的。用哪些代碼能將他們二個連接起來

1、html是用來做網頁的表現層的,也就可以看到的。如字體、鏈接,圖片等。
2、php是用來處理邏輯層的,也就是網頁提供什麼功能,完成什麼動作。如查詢數據,計算利息,生成圖表等。
3、php代碼是嵌入html中的。

④ php和html代碼怎麼弄到一起

你這是屬於混編了 我做的其實就這個 呵呵
舉個最簡單的例子 就用你這個來做
<?
if($num>0){
while($rs=mysql_fetch_array($result)){
?>
<a href='forum.php?page=1&numb=".<?=$rs['id']?>."'>".<?=$rs['name']?>."</a></br>
<?
}
}else{
echo "對不起,論壇尚在建設中……";
}
?>
####<?=$rs['id']?>這個是因為我電腦里開了短標簽 所以 可以這么寫 如果你電腦里也開了短標簽也可以這么些 但是不建議這么做

⑤ php如何與html實現混編

混編如果是php原生態的話就直接嵌入,用框架的話有點不同的

⑥ PHP里如何套html

一般來說有兩種混合寫法,一種是HTML套PHP,寫作<?php ?>;另一種是PHP套HTML,寫作<?php echo ?> ,若php開啟短標簽寫法,也可寫作<?=$item['RAND']?>
還有一種不太常用的混合寫法如下:
easy way to execute conditional html / javascript / css / other language code with php if else:
<?php if (condition):?>
html code to run if condition is true
<?php else: ?>
html code to run if condition is false
<?php endif ?>
列出項目中的一段代碼的兩種寫法:
[php] view plain
<?php if($resitem['PREVIEW']){echo $resitem['PREVIEW'];} else {echo "static/images/bg72.png";}?>
寫法二:
[php] view plain
<?php if($resitem['PREVIEW']): ?> <?=$resitem['PREVIEW']?><?php else: ?>static/images/bg72.png<?php endif ?>

⑦ 開啟php與html混編

首先,你要混編的話你的文件後綴必須是php ,這樣伺服器才會編譯裡面的php語句,而不是直接輸出。
其次,你混編的代碼可能是<? echo 'xxx'; ?>形式的,而不是<?php echo 'xxx'; ?>形式的。使用第一種方法需要在php.ini裡面設置。
最後,你顯示不了的文件應該在瀏覽器右鍵查看源代碼,可以幫助你分析出錯原因,例如html和php代碼都被輸出了,就是第一個原因。如果有html代碼,沒有php代碼輸出,錯誤原因可能是你的php代碼出錯。實在找不出問題原因,可以把代碼貼出來~

⑧ PHP 與HTML的混編

混編的話,如果你想稍微修改點,你會改動大量的HTML,
如果能使用邏輯模板,使得程序和界面分離,很多時候會使得開發事半功倍。

⑨ 一個php 文件與多個html文件如何進行交互

<?php

header("Content-type: text/html; charset=gb2312");

header("Pragma: no-cache");

header("Expires: 0");

@$action = $_REQUEST ['action'];

$sid = MyTool::generateId ();

if (! $action)

$action = "list";

Trace::debug ( $action );


if ($action == "save") {

$reply = $_REQUEST ['reply'];//獲取回復值

print_r($reply);

$id = $_REQUEST ['f_id'];

CourseService::updateApplyState($db,$id,TrainApply::STATUS_PASS);


$apply=CourseService::getTrainApply($db,$id);


$student=$apply->owner;

$trainId=$apply->train;


$train=CourseService::getTrainSchele($db,$trainId);


$pass_test=$train->test==""?0:-1;

$pass_judge=$train->judge==""?0:-1;

$pass_readrate=$train->readrate==""?0:-1;

$pass_feedback=$train->feedback==""?0:-1;


$mc = new MyCourse();

$mc->schele_id = $train->id;

$mc->course_id = $train->course_id;

$mc->user_id = $student;

$mc->type = $train->catalog;

$mc->state = MyCourse::STATE_WAITING;

$mc->pass_test = $pass_test;

$mc->pass_judge =$pass_judge ;

$mc->pass_feedback = $pass_feedback;

$mc->pass_readrate = $pass_readrate;

$mc->score = $train->score;

$mc->starttime = $train->starttime;

$mc->endtime = $train->endtime;

$mc->coursename = $train->name;

CourseService::save($db, $mc);


print"<script>alert('通過操作成功!');window.close();location.href='applyreply.php?action=list'</script>";

}

if ($action == "reject") {

$id = $_REQUEST ['f_id'];

$sql = "update t_train_apply set f_status=2 where f_id='".$id."'";

Trace::debug ( $sql );

$db->Execute ( $sql );

print"<script>alert('拒絕操作成功!');window.close();location.href='applyreply.php?action=list'</script>";

}

if ($action == "list") {

$pagination = new MyPagination(0,1);

$UserID = $_SESSION[AuthorizationHelper::SESSION_USER_KEY]['id'];

$as = CourseService::listApply($db,$pagination,null,null,null,$UserID);

//print_r($as);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>無標題文檔</title>


<?= HTMLTool::includeResource() ?>

<link href="../css/css.css" rel="stylesheet" type="text/css" />

<script language="JavaScript">

$(function() {

$('#tabs').tabs({spinner:'載入...',fx:{ opacity: 'toggle' },selected:2});

});

function passIt(id){

var url = '<?php print $_SERVER['PHP_SELF'] ?>';

var pars = 'action=pass&f_id='+id;

alert(url+"?"+pars);

// open(url+"?"+pars);

var myAjax = new Ajax.Request(

url,

{

method: 'get',

parameters: pars,

onComplete:done

});

afterPass(id);

}


function afterPass(id){

// alert(originalRequest.responseXML);

// var result = originalRequest.responseXML.getElementsByTagName("id");

// alert(result.length);

document.getElementById('button_'+id).style.display='none';

document.getElementById('status_'+id).innerHTML='通過';

}

function rejectIt(id){

var url = '<?php print $_SERVER['PHP_SELF'] ?>';

var pars = 'action=reject&f_id='+id;

//alert(url+"?"+pars);

var myAjax = new Ajax.Request(

url,

{

method: 'get',

parameters: pars,

onComplete:done

});

afterReject(id);

}


function afterReject(id){

// alert(originalRequest.responseXML);

// var result = originalRequest.responseXML.getElementsByTagName("id");

// alert(result.length);

document.getElementById('button_'+id).style.display="none";

document.getElementById('status_'+id).innerHTML="駁回";

}


function done(){

alert("操作成功");

}

</script>

</head>


<body >

<!-- 導航欄 -->

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="navigationbar" class="navigationbar">

<tr><td height="28" >您現在的位置: <a href="../welcom.php">首頁</a> >> <a href="#">考試管理</a> >>考試申請管理</td></tr>

</table>

<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center">

<tr>

<td valign="top">

<table width="100%" border="0" cellpadding="1" cellspacing="1" class="listtable">

<thead>

<tr>

<td width="150">考試名稱</td>

<td>申請原因</td>

<td width="150">申請人</td>

<td width="130">申請時間</td>

<td width="80">狀態</td>

<td width="80">管理</td>

</tr>

</thead>

<?php

//foreach($as as $a){

//Trace::debug($a);

//$schele = CourseService::getTrainSchele($db,$a->train);

//$u = UserService::getUser($db,$a->owner);

?>

<tr>

<td><?= $schele->name ?></td>

<td><?= $a->name ?></td>

<td><?= $u->trueName ?></td>

<td><?= MyTool::formatDate($a->createtime)?></td>

<td><span id="status_<?= $a->id ?>"><?= TrainApply::$STATUS_ARRAY[$a->status]?></span></td>

<td>&nbsp;<span id="button_<?= $a->id ?>">

<?php if($a->status==TrainApply::STATUS_WAITING) {?>

<a href="?action=pass&f_id=<?= $a->id ?>">通過</a>&nbsp;

<a href="application_manage.php?action=reject&f_id=<?= $a->id ?>">拒絕</a>

<?php } ?>

</td>

</tr>

<?php //} ?>

</table>

<?php include($_SERVER['DOCUMENT_ROOT']."/train/common/pagination.php")?>

</td>

</tr>

</table>


</body>

</html>

<?php }?>

<?php if($action=="pass") {//回復

?>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>無標題文檔</title>


<?= HTMLTool::includeResource() ?>

<script >

$(document).ready(function(){

$("#commonForm").validate();

});

</script>

</head>


<body>


<table width="98%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_up"></td>

<td class="border_middle_up"><span class="pagetitle">建議回復</span></td>

<td class="border_right_up"></td>

</tr>

</table>

</td>

</tr>

<tr>

<td align="center">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_middle">&nbsp;</td>

<td align="center">

<form id="commonForm" method="post">

<input type="hidden" name="action" value="save"/>

<input type="hidden" name="id" value="<?php print $_REQUEST ['id']?>" />

<textarea class="required" rows="10" cols="120" name="reply" maxlength="500">您的建議已採納,謝謝參與</textarea><br>

<span class="btn_green"><span><button type="submit" id="sure">提 交</button></span></span>

</form>

</td>

<td class="border_right_middle">&nbsp;</td>

</tr>

</table>

</td>

</tr>

<tr>

<td><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="border_left_down"></td>

<td class="border_middle_down">&nbsp;</td>

<td class="border_right_down"></td>

</tr>

</table></td>

</tr>

</table>

</body>

</html>


<?php } ?>

閱讀全文

與phphtml混編教程相關的資料

熱點內容
手機如何連接伺服器的遠程桌面 瀏覽:48
復雜命令的實現 瀏覽:330
抖音上的程序員和真正的程序員 瀏覽:300
查看kernel編譯器 瀏覽:279
給plc程序加密 瀏覽:225
python多進程數據共享 瀏覽:847
華為和安卓系統有什麼不一樣 瀏覽:106
python中wb表怎麼列印 瀏覽:297
python如何把字元串賦給數組 瀏覽:229
狄克斯特拉演算法是什麼 瀏覽:675
室內裝飾材料pdf 瀏覽:633
gitbook命令行 瀏覽:1000
啟動zookeeper命令 瀏覽:527
健身館app怎麼樣 瀏覽:314
python可視化項目 瀏覽:442
安卓機怎麼辨別蘋果機真假 瀏覽:711
微信小程序源碼轉成抖音 瀏覽:654
優省油app怎麼沒法下載 瀏覽:72
pdf格式轉換excel 瀏覽:625
高爾夫6壓縮機響 瀏覽:310