如何在netbeans 8.0.1的html代码中使用php代码?
我可以创建一个新的php项目,但我想创建一个我创建的html5项目,在里面我还想使用php代码 除了下载和使用netbeans之外,我还下载并使用xampp。 运行xampp后,我单击了apache上的start 现在要浏览到我的测试站点,我将:如何在netbeans 8.0.1的html代码中使用php代码?,php,html,.htaccess,netbeans,Php,Html,.htaccess,Netbeans,我可以创建一个新的php项目,但我想创建一个我创建的html5项目,在里面我还想使用php代码 除了下载和使用netbeans之外,我还下载并使用xampp。 运行xampp后,我单击了apache上的start 现在要浏览到我的测试站点,我将: http://localhost:8383/HTML5Application1/index.html 这是一个免费的模板,我下载只是为了测试。 在我的网站中,我试图在html文件中使用php的页面是: http://localhost:8383/HT
http://localhost:8383/HTML5Application1/index.html
这是一个免费的模板,我下载只是为了测试。
在我的网站中,我试图在html文件中使用php的页面是:
http://localhost:8383/HTML5Application1/images%20slideshow.html
slideshow.html文件内容如下所示:
<?php
$pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$) |(\.Gif$)"; //valid image extensions
$files = array();
$curimage=0;
if($handle = opendir($"http://newsxpressmedia.com/files/radar-simulation-files")) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){ //if this file is a valid image
//Output it as a JavaScript array element
$files[] = $file;
$curimage++;
}
}
closedir($handle);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>change picture</title>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type='text/css'>
#Timer_Countdown{
background:black;
color:yellow;
font-weight:bold;
text-align:center;
}
</style>
<script type = "text/javascript">
function displayNextImage() {
x = (x === images.length - 1) ? 0 : x + 1;
document.getElementById("img").src = images[x];
}
function displayPreviousImage() {
x = (x <= 0) ? images.length - 1 : x - 1;
document.getElementById("img").src = images[x];
}
//$json = json_encode($files);
//json = <?php echo $json; ?>
//var images = JSON.parse(json);
//var images = <?=json_encode($files)?>;
var images = [];
var x = -1;
var swap_hours = 0;
var swap_minutes = 0;
var swap_seconds = 5;
var down_counter_hours;
var down_counter_minutes;
var down_counter_seconds;
function initTimer() {
down_counter_hours = swap_hours;
down_counter_minutes = swap_minutes;
down_counter_seconds = swap_seconds;
counter = setInterval(switcher, 1000);
}
function restartCounter() {
down_counter_hours = swap_hours;
down_counter_minutes = swap_minutes;
down_counter_seconds = swap_seconds;
}
function switcher() {
down_counter_seconds--;
if (down_counter_hours <= 0 && down_counter_minutes <= 0 && down_counter_seconds <= 0) {
swapColor();
restartCounter();
}
if (down_counter_seconds <= 0 && down_counter_minutes > 0) {
down_counter_seconds = 60;
down_counter_minutes--;
}
if (down_counter_minutes <= 0 && down_counter_hours > 0) {
down_counter_minutes = 60;
down_counter_hours--;
}
document.getElementById("Timer_Countdown").innerText = down_counter_hours+":"+down_counter_minutes+":"+down_counter_seconds;
}
function swapColor() {
displayNextImage();
}
</script>
<div id="div_hours" class="div_box"></div>
<div id="div_minutes" class="div_box"></div>
<div id="div_seconds" class="div_box"></div>
<div id="div_switcher" class="div_box"></div>
</head>
<body onload = "initTimer()">
<div id="Timer_Countdown"> </div>
<img id="img" src="http://newsxpressmedia.com/files/theme/radar000005.Gif">
<button onclick="displayPreviousImage(); restartCounter()">Previous</button>
<button onclick="displayNextImage(); restartCounter()">Next</button>
</body>
</html>
改变形象
#定时器倒计时{
背景:黑色;
颜色:黄色;
字体大小:粗体;
文本对齐:居中;
}
函数displayNextImage(){
x=(x==images.length-1)?0:x+1;
document.getElementById(“img”).src=images[x];
}
函数displayPreviousImage(){
x=(x;
var图像=[];
var x=-1;
var交换时间=0;
var交换分钟数=0;
var swap_秒=5;
var停机时间;
var下降计数器分钟数;
var下降\u计数器\u秒;
函数initTimer(){
停机时间=交换时间;
下行计数器分钟数=交换分钟数;
下降计数器秒数=交换秒数;
计数器=设置间隔(开关,1000);
}
函数restarcounter(){
停机时间=交换时间;
下行计数器分钟数=交换分钟数;
下降计数器秒数=交换秒数;
}
函数切换器(){
下计数器秒--;
如果(关闭\u计数器\u小时,除非另有指示,否则php解析器不会解释html页面,因此首先将文件扩展名从.html
更改为.php
,但稍后,如果我上传我的网站,索引文件将是index.php,其中包含html和php代码,那么它仍将像index.html一样工作?我的意思是什么不同index.html和index.php之间的区别?唯一的区别是,在index.php中,我还可以将php代码与html一起使用?