Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在有限控制的共享主机上观察/记录php代码中的变量值?_Php_Debugging - Fatal编程技术网

如何在有限控制的共享主机上观察/记录php代码中的变量值?

如何在有限控制的共享主机上观察/记录php代码中的变量值?,php,debugging,Php,Debugging,我正在调试安装在共享主机(linux、cpanel、PHP5.2)上的php系统。我发现我遇到的问题是php文件中的一个函数。我想看看在执行该文件时,该文件中所有变量的值是什么 我尝试用mail()将变量值发送给我自己,但没有成功。 我还尝试了error函数,以便读取错误日志文件,但主机中没有创建任何文件,或者错误文件中没有消息。我尝试了以下错误函数 error_log("Err!", 0); error_log("Err", 1,"operator@example.com"); error_l

我正在调试安装在共享主机(linux、cpanel、PHP5.2)上的php系统。我发现我遇到的问题是php文件中的一个函数。我想看看在执行该文件时,该文件中所有变量的值是什么

我尝试用mail()将变量值发送给我自己,但没有成功。 我还尝试了error函数,以便读取错误日志文件,但主机中没有创建任何文件,或者错误文件中没有消息。我尝试了以下错误函数

error_log("Err!", 0);
error_log("Err", 1,"operator@example.com");
error_log("Err", 3, "/my-errors.log");
我使用的是来自namecheap的共享主机,它不提供所有功能,也不提供对所有日志的访问

你知道我如何检查这个特定函数中发生了什么,以及在执行时它的变量值是什么吗

非常感谢

如果有帮助,相关功能如下所示:

/**
 * Reset a user's password
 * @param $args array first param contains the username of the user whose password is to be reset
 */
function resetPassword($args, &$request) {
    $this->validate();
    $this->setupTemplate($request);
    $site =& $request->getSite();
    $oneStepReset = $site->getSetting('oneStepReset') ? true : false;

    $username = isset($args[0]) ? $args[0] : null;
    $userDao =& DAORegistry::getDAO('UserDAO');
    $confirmHash = $request->getUserVar('confirm');

    if ($username == null || ($user =& $userDao->getByUsername($username)) == null) {
        $request->redirect(null, null, 'lostPassword');
    }

    $templateMgr =& TemplateManager::getManager();

    $hash = Validation::generatePasswordResetHash($user->getId());
    if ($hash == false || $confirmHash != $hash) {
        $templateMgr->assign('errorMsg', 'user.login.lostPassword.invalidHash');
        $templateMgr->assign('backLink', $request->url(null, null, 'lostPassword'));
        $templateMgr->assign('backLinkLabel',  'user.login.resetPassword');
        $templateMgr->display('common/error.tpl');

    } else if (!$oneStepReset) {
        // Reset password
        $newPassword = Validation::generatePassword();

        if ($user->getAuthId()) {
            $authDao =& DAORegistry::getDAO('AuthSourceDAO');
            $auth =& $authDao->getPlugin($user->getAuthId());
        }

        if (isset($auth)) {
            $auth->doSetUserPassword($user->getUsername(), $newPassword);
            $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only
        } else {
            $user->setPassword(Validation::encryptCredentials($user->getUsername(), $newPassword));
        }

        $user->setMustChangePassword(1);
        $userDao->updateObject($user);

        // Send email with new password
        import('classes.mail.MailTemplate');
        $mail = new MailTemplate('PASSWORD_RESET');
        $this->_setMailFrom($request, $mail, $site);
        $mail->assignParams(array(
            'username' => $user->getUsername(),
            'password' => $newPassword,
            'siteTitle' => $site->getLocalizedTitle()
        ));
        $mail->addRecipient($user->getEmail(), $user->getFullName());
        $mail->send();
        $templateMgr->assign('pageTitle',  'user.login.resetPassword');
        $templateMgr->assign('message', 'user.login.lostPassword.passwordSent');
        $templateMgr->assign('backLink', $request->url(null, $request->getRequestedPage()));
        $templateMgr->assign('backLinkLabel',  'user.login');
        $templateMgr->display('common/message.tpl');
    } else {
        import('classes.user.form.LoginChangePasswordForm');

        $passwordForm = new LoginChangePasswordForm($confirmHash);
        $passwordForm->initData();
        if (isset($args[0])) {
            $passwordForm->setData('username', $username);
        }
        $passwordForm->display();
    }
}

我会在函数的末尾使用一个var_转储,就像这样。将为您提供所有数据,如果您将其包装在标签中,它看起来会更好

echo "<pre>";
var_dump(get_defined_vars());
echo "</pre>";
echo”“;
var_dump(get_defined_vars());
回声“;
或者对您的$this var执行此操作