简体   繁体   English

如何在服务器上调试php post脚本并查看echo输出

[英]how to debug a php post script on the server and see echo output

newbie question. 新手问题。 I have a web page sending $_POST data to a php script on a server. 我有一个网页,将$ _POST数据发送到服务器上的php脚本。 How to debug php (see the output of echo) ? 如何调试php(请参见echo的输出)? If I just browse to the www.serveradress.com/myscript.php,I see nothing... I am using Chrome. 如果我只是浏览到www.serveradress.com/myscript.php,我什么也看不到...我正在使用Chrome。

Thanks 谢谢

Edit: I am using ngFileUpload on the client side. 编辑:我在客户端上使用ngFileUpload。 Edit: I see that the file is well received because I see it on the server with filezilla. 编辑:我看到该文件受到好评,因为我在使用filezilla的服务器上看到了该文件。

client side: 客户端:

$scope.uploadBoardPic = function(file, errFiles) {
    $scope.boardPic = file;
    $scope.errFile = errFiles && errFiles[0];
    if (file) {
        file.upload = Upload.upload({
            url: 'http://myserver.com/angular-seed/appendBoardPicture.php',
            method: 'POST',
            data: {file: file}
        });

        file.upload.then(function (response) {
            $timeout(function () {
                file.result = response.data;
            });
        }, function (response) {
            if (response.status > 0)
                $scope.errorMsg = response.status + ': ' + response.data;
        }, function (evt) {
            file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
        });
    }   
}

server side: 服务器端:

<?php
$filename = $_FILES['file']['name'];
$destination = './' . $filename;
move_uploaded_file( $_FILES['file']['tmp_name'] , $destination );

echo "<pre>" . print_r($_FILES, true) . "</pre>";
?>

Php keeps POST variables within the $_POST global. Php将POST变量保留在$ _POST全局范围内。 You should be able to run something to the affect of 您应该能够运行某些影响

echo "<pre>" . print_r($_POST, true) . "</pre>";

To get back the debugging information you need. 要获取调试信息,您需要。 This of course will only work if you are doing a valid POST via a form. 当然,这仅在您通过表单进行有效的POST时才有效。 That meaning that the page is actually going to change. 这意味着页面实际上将要更改。 Looking at your question though, it looks like you are working in all javascript for your post/reply. 不过,看着您的问题,您似乎正在使用所有JavaScript进行发布/回复。 In that case, you will want to look for the reply information from php, within your javascript. 在这种情况下,您将需要在javascript中查找来自php的回复信息。 You can do this by looking at the network tab, during the submission. 您可以通过在提交过程中查看“网络”标签来做到这一点。

As a good practice, you should use error logs for this kind of task. 作为一种好习惯,应该将错误日志用于此类任务。 If you have not set up a error log then you should set it up in the apache config file. 如果尚未设置错误日志,则应在apache配置文件中进行设置。

Once you set the error log simply type this: 设置错误日志后,只需键入以下内容:

error_log(var_export($_POST, true));

and you can see the exports in your error log. 并且您可以在错误日志中看到导出。

http://php.net/manual/en/function.error-log.php http://php.net/manual/en/function.error-log.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM