我有我的1and1托管网站.我有需要调试的服务器端php.当我在本地 Web服务器上有一个带有php和mysql的本地 Web服务器时,我发现所有提到运行/安装xdebug .
但是,我正在使用托管在1and1主机上的远程Web服务器.我正在使用和喜欢netbeans,哇伟大的IDE.
无论如何,如何(如果它甚至可能)我可以安装然后使用xdebug调试器来调试我在Netbeans中运行1and1的php代码?
我想知道是否是我的托管公司(1and1)必须安装xdebug.我正在运行最新版本的Netbeans但是当我按下工具栏上的调试按钮时,我看到一条错误消息弹出窗口显示
"xdebug在40秒内没有检测到连接.原因可能是xdebug既未安装也未正确配置.请确保您的php.ini文件包含以下条目:
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost (or hostname)
xdebug.remote_port=9000
Run Code Online (Sandbox Code Playgroud)
所以我搜索了我的硬盘,尽管安装了完整的Netbeans IDE,但我没有php.ini文件.
所以我可以远程使xdebug工作,即.我可以调试我的PHP代码,因为它运行在远程1and1 Web服务器上,使用Netbeans和xdebug?
我只使用Netbeans 2天,据我所知,xdebug甚至不是Netbeans的一部分.我说的原因是,我可以远程"运行"我的PHP - 它在远程1and1 Web服务器上执行,当我在Netbeans中推送'run'时 - 然后我本地机器上的客户端输出是正确的.但是我不能通过按Netbeans工具栏上的"调试"按钮来使用xdebug进入代码 - 是否有可能xdebug无法正确安装Netbeans?
我正在调用一个var_dump()或print_r()在一个echo语句中有一个值的数组:
echo "<br><br>testArray is ==> " . var_dump($testArray) . " <===<br><br>";
Run Code Online (Sandbox Code Playgroud)
这是浏览器中的实际输出:
array
0 => string '28' (length=2)
testArray is ==> <===
Run Code Online (Sandbox Code Playgroud)
这是我无法得到的细微差别.对我来说,执行的顺序是:
testArray is ==><==应该执行而不是在输出上看到1,2,然后是3,我2, 1, 3按顺序看到了.这是一行服务器端代码.这个细微差别是什么?
getElementById()正在返回对表单上检索"隐藏"字段的调用null.
我已经研究了其他SO问题,许多人在调用中使用隐藏字段的'name'而不是'id',getElementById()或者getElementById()在包含隐藏字段的实际html处理之前在文件顶部的脚本中执行浏览器.这两个错误都可以解释为什么getElementById()要返回null它们.
我可能错了,但我不认为这是我的情况.
这是我的表格:
<form name="theDeleteItemForm" id="deleteItemForm" action="deleteTheSelectedItem"
method="post"
<input type="hidden" id="theHiddenField" name="deleteThisSelectedItem" value="">
</form>
Run Code Online (Sandbox Code Playgroud)
这里有一个Javscript处理程序,当点击页面上的"删除"按钮时,它成功执行(我可以告诉我alert(),因为我在下面的处理函数中弹出了框):
function deleteItem()
{
alert("Just entered deleteItem()");
var theFieldToDelete = document.getElementById('theHiddenField');
// THIS IS THE PLACE WHERE I FOUND THAT 'theFieldToDelete' WAS 'null'
alert("Just got the hidden field element, which is: " + theFieldToDelete );
// THIS DOES NOTHING MORE THAN TO PREVENT THE 'alert' THAT FOLLOWS FROM APPEARING
theFieldToDelete.value …Run Code Online (Sandbox Code Playgroud) 我在3周前写了一个heredoc,它工作得很好,直到今天它还使用了5个php变量.
这是heredoc:
echo <<<itemDetails_HEREDOC
<img src="$sitePath/images/logo-landing2.png" />
<form action="$thisFilename" method="post" name="arti-form" id="arti-formId">
<label style="display: inline-block; width: 140px">OWNER NAME:</label><input type="text" style="width: 300px"
id="ownerId" name="ownerName" readonly="readonly" value="$theLoggedInUser" /><br />
<label style="display: inline-block; width: 140px">THE ITEM:</label><input type="text" style="width: 300px"
readonly="readonly" id="itemNameId" name="itemName" value="$itemName" /><br />
<label style="display: inline-block; width: 140px">LINK:</label><input type="text" style="width: 300px"
readonly="readonly" id="itemLinkId" name="link" value="$theLinkID" /><br />
<label style="display: inline-block; width: 140px">ERA:</label><input type="text" style="width: 70px"
readonly="readonly" id="itemEraId" name="itemEra" value="$itemEra" /><br />
itemDetails_HEREDOC;
Run Code Online (Sandbox Code Playgroud)
上面的heredoc中有六(6)个php变量.第一个($ sitePath)不工作.我今天刚加了.
由于某种原因,服务器没有正确替换'$ sitePath'(我的heredoc中的第一个php变量),因为当浏览器收到上述页面时,会产生错误:
Notice: Undefined variable: sitePath in …Run Code Online (Sandbox Code Playgroud) 在播放视频结束时,jwplayer会显示一个覆盖整个jwplayer矩形的"共享"用户界面 - 这是一个带有3个标签的标签窗口,'分享','嵌入','信息'.我需要让这个"分享"用户界面消失.
为了替换这个"共享"用户界面,我假设Jwplayer在完成视频播放作为标准行为之后就出现了 - 我为onIdle,onComplete和onReady事件添加了事件处理程序.
在事件处理程序中,我完全按照代码在创建播放器时执行的操作:我使用默认视频和默认图像加载播放列表:
// this is called immediately after jwplayer.setup()
jwplayer().onComplete(function playerOnCompleteEvent(){handlePlayerComplete(jwplayer);});
// this gets called for the onComplete event
function handlePlayerComplete(theJwPlayer)
{
playlist = { file: 'http://localhost/theWebsite/videos/moto_sounds.flv',
image: 'http://localhost/theWebsite/images/mybanner2.jpg' };
alert("in handlePlayerIdle: the playlist file is "
+ playlist.file + " and image is " + playlist.image);
theJwPlayer().load(playlist);
}
Run Code Online (Sandbox Code Playgroud)
"警告"框告诉我播放列表文件和图像是正确的.我知道我的事件处理程序正在被调用 - 我在处理程序中使用一个警告框来证明这一点.
但"共享"3标签窗口不会消失.播放后仍然存在 - onIdle和onReady都使用上面相同的代码 - 没有帮助.
'分享'用户界面 - 如何在视频播放完成后用'mybanner2.jpg'替换它?
超过1小时.这是我的index.php文件中的javascript代码.
function dostuff()
{
var thepath = document.location.search.substring(1);
alert('the path is ' + thepath + " (that's the full path)");
alert(thepath);
// TRIED THESE ALL -- NONE OF THEM WORK.
//var pathLen = String.length("thepath");
//var pathLen = String.length(thepath);
//var pathLen = thepath.length();
var pathLen = String.length(document.location.search.substring(1));
alert('pathLen is ' + pathLen);
}
Run Code Online (Sandbox Code Playgroud)
症状:前2个警告框出现没问题,两个都显示'thepath'中有一个有效的路径名,它也是正确的预期路径.
但无论我尝试什么 - 看到4个不同的尝试,一次尝试一个 - 最终警报()框永远不会出现.为什么警报('pathLen是'+ pathLen)没有出现?
(另一件事是 - 我正在使用XDEBUG和xampp以及Netbeans,调试器不会让我在这个javascript代码中放置一个断点,所以我甚至无法进入它看看发生了什么,因此使用了代码中的alert().我知道我在Netbeans中使用的XDEBUG调试器工作 - 我一直在使用它来调试另一个.PHP文件中的PHP代码.当我在任何设置断点时Javascript代码,出现"断开的断点"图标,我无法找到Netbeans文档中的含义.)
我看了,但没有找到我在这里的情况 - 很多先前的答案说'等待'onload'来调用getElementById'但这就是我开始使用它并且它不起作用 - getElementById返回null我的index.php文件中的这段代码:
<html>
<script type="text/javascript">
function checkPwd()
{
var thePwd = document.getElementById("theUsersPassword");
alert("the var thePwd is: " + thePwd);
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Beta:</title>
</head>
<body onload="checkPwd()">
<form method="post" action="index.php">
Beta: <input name="theUsersPassword" type="password"><br/>
<input type="submit" value="Submit" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 为了准备稍后转移到生产服务器,我正在使用此代码(php)创建一个用于存储用户文件的新目录:
function createNewUserFolder($newUserName)
{
$siteRoot = "http://" . $_SERVER['HTTP_HOST'] . "/myWebsite/";
$newUserSubfolder = $siteRoot . $newUserName;
if (!mkdir($newUserSubfolder, 0755))
{
echo "PROBLEM...";
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了0644权限无济于事 - 我执行时只会遇到'问题...'.我检查包含完整路径的字符串,它是正确的 - "http:// localhost/myWebsite/myNewUserSubfolder".
所以我怀疑上面字符串中的"http:// localhost/myWebsite /"部分是问题所在.但我不明白为什么 - 毕竟,这是我的网络服务器上运行的PHP代码,为什么我的PHP代码不能在我的网络服务器上创建一个文件夹?
我需要在网站的不同页面上访问我的JW Player对象以加载播放列表.
所以我添加了一行代码,播放器就消失了!
<?php $_SESSION['theJwPlayer'] = jwplayer; ?>
Run Code Online (Sandbox Code Playgroud)
我在任何需要访问$ _SESSION的页面的顶部使用以下内容:
session_start();
Run Code Online (Sandbox Code Playgroud)
这是播放器的创建,这个工作正常,超过一周,除了最后一行代码:
<script type="text/javascript">
jwplayer('mediaplayer').setup({
'flashplayer': 'http://localhost/theWebsite/jwplayer/player.swf',
'id': 'playerID',
'width': '480',
'height': '270',
'file': 'http://localhost/theWebsite/videos/moto_sounds.flv',
'image': 'http://localhost/theWebsite/images/banner2.jpg'
});
// now save the player in a session variable
<?php $_SESSION['theJwPlayer'] = jwplayer; ?>
</script>
Run Code Online (Sandbox Code Playgroud)
如果我只删除那个将播放器存储在_SESSION数组中的那一行php代码,那么播放器的网页会恢复正常,它们已经持续了一周以上,稳定,JW播放器显示,没问题.但添加这一行,播放器消失:
我以为会话会自动序列化对象?为什么这一行代码"消失"了我的jwplayer对象?
我尝试在jwplayer之前添加$,如同
<?php $_SESSION['theJwPlayer'] = $jwplayer; ?>
Run Code Online (Sandbox Code Playgroud)
没有变化,玩家消失了.这里发生了什么事?
我在整个项目中使用以下内容,直到现在都没有注意到一个问题:
include '../titleBar.php';
require_once '../navBar.php';
require_once '../theDatabase.php'; // functions for the UI and DB access
require_once '../globals.php'; // variables and statics used throughout
Run Code Online (Sandbox Code Playgroud)
上面的FINE工作了3个星期.文件名之前../的原因是:上述语句出现在用户特定文件(如FOO_x.php)中的用户子文件夹中,这些文件特定于用户输入的数据 - 只有上面的include和require_once文件涉及公共代码,公共代码是根网站目录中子文件夹上方的一个目录.
所以我添加了这个新的代码,它没有引入样式表:
include '../titleBar.php';
require_once '../navBar.php';
require_once '../theDatabase.php';
require_once '../globals.php';
<html>
<head>
<link rel="stylesheet" type="text/css" href="../globalStyles.css" />
Run Code Online (Sandbox Code Playgroud)
我将其更改为此,并将样式表拉到用户特定的文件FOO_x.php中:
<link rel="stylesheet" type="text/css" href="globalStyles.css" />
Run Code Online (Sandbox Code Playgroud)
KEEP IN MIND - 上面的链接rel位于根网站子目录中的文件FOO_x.php中.AND - 文件'globalStyles.css'是.....不在FOO_x.php所在的子目录中.
文件'globalStyles.css'是包含FOO_x.php的文件夹的一个级别.
那么为什么/怎么可能href = globalStyles.css工作呢?好吧,它做到了.
因为在过去3周内,FOO_x.php顶部的include/require列表中的第二个文件"navBar.php"中包含以下语句:
<base href='http://localhost/theSiteRootFolder/'></base>
Run Code Online (Sandbox Code Playgroud)
所以,当我尝试
<link rel="stylesheet" type="text/css" href="../globalStyles.css" />
Run Code Online (Sandbox Code Playgroud)
并且没有一个样式出现在FOO_x.php页面上,我将其切换为
<link rel="stylesheet" type="text/css" href="globalStyles.css" />
Run Code Online (Sandbox Code Playgroud)
突然出现了风格.然后我记得'很久以前'我把'base'语句放在navBar.php中.
接下来我想"好吧,如果链路相对语句使用'基地’的语句从navBar.php …
经过多年的写作,我正在学习所有这些网络编程的东西.EXE Windows程序所以请耐心等待.我开发了一个基本的.php和mysql网站,工作正常.
但我去了我的index.php添加javascript代码,我不认为javascript代码正在执行.
我的index.php有以下形式:
<?php
require_once blah blah
call_my_php_functionBlah();
?>
Run Code Online (Sandbox Code Playgroud)
然后我将这段代码添加到'<\?\ php'和"\?>"的php块中,如下所示:
<script type="text/javascript">
// some known-good javascript code that displays an image
</script>
Run Code Online (Sandbox Code Playgroud)
什么都没有出现.所以我想"啊啊啊,我吹了它,我需要做的就是 - 在php块之外移动javascript代码,在index.php的底部,我当然很高兴."
而且,没有出现任何事情.
我检查了我的'已知良好'javascript代码的来源,它说"将这个javascript代码嵌入到你的HTML文件中",所以我想"哇,我想我需要一个index.html或者其他东西."
所以我的问题:
1)我的index.php应该能够运行javascript代码块吗?我猜'不是因为index.php在服务器上执行而javascript在客户机上运行.'
2)如果我想保留我的index.php,我应该如何构建它,其代码工作正常并且我不想弄乱它?
我认为这是一个非常基本的客户端/服务器,php和javascript脚本组织问题,每个Web程序员都知道如何处理,但就像我说的,我对这一切都是新手.我在档案中读到了关于.htaccess等等但是我打赌这是一种更简单的方法,我不确定我读过的东西是否适用.