1

我正在编写一个相当大的 PHP 应用程序,并且已经到了想要一些调试输出的地步。我已经成功安装了 FireBug 和 FirePHP,并且成功地向控制台输出了一行文本。

这是现在的问题。我有一个名为 Register.php 的 php 文件,它基本上只包含用于显示视图和提交表单的代码。该文件调用 SiteViewModel.php 类中的函数来完成注册用户的实际后台工作。SiteViewModel.php 还调用其他 php 文件以连接到数据库并执行检查/插入。

如果我将调试行放在 SiteViewModel.php 文件构造函数中,我会得到 Firebug 控制台的输出。如果我将任何其他行放在其他任何地方,我什么都不会记录。

一些代码

注册.php:

<?php
require_once("/xampp/htdocs/SiteConfig.php");

if(isset($_POST['submitted']))
{
   if($rlrpgSite->RegisterUser())
   {
        $rlrpgSite->RedirectToURL("registrationthanks.php");
   }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    <title>Register</title>
    <link rel="STYLESHEET" type="text/css" href="../style/fg_membersite.css" />
    <script type='text/javascript' src='../scripts/gen_validatorv31.js'></script>
    <link rel="STYLESHEET" type="text/css" href="../style/pwdwidget.css" />
    <script src="../scripts/pwdwidget.js" type="text/javascript"></script>      
</head>
<body>

<!-- Form Code Start -->
<div id='fg_membersite'>
<form id='register' action='<?php echo $rlrpgSite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >
<legend>Register</legend>

<input type='hidden' name='submitted' id='submitted' value='1'/>

<div class='short_explanation'>* required fields</div>
<input type='text'  class='spmhidip' name='<?php echo $rlrpgSite->GetSpamTrapInputName(); ?>' />

<div><span class='error'><?php echo $rlrpgSite->GetErrorMessage(); ?></span></div>
<div class='container'>
    <label for='firstname' >First Name*: </label><br/>
    <input type='text' name='FirstName' id='FirstName' value='<?php echo $rlrpgSite->SafeDisplay('FirstName') ?>' maxlength="100" /><br/>
    <span id='register_firstname_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='lastname' >Last Name*: </label><br/>
    <input type='text' name='LastName' id='LastName' value='<?php echo $rlrpgSite->SafeDisplay('LastName') ?>' maxlength="100" /><br/>
    <span id='register_lastname_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='email' >Email Address*:</label><br/>
    <input type='text' name='EmailAddress' id='EmailAddress' value='<?php echo $rlrpgSite->SafeDisplay('EmailAddress') ?>' maxlength="512" /><br/>
    <span id='register_email_errorloc' class='error'></span>
</div>
<div class='container'>
    <label for='username' >UserName*:</label><br/>
    <input type='text' name='UserName' id='UserName' value='<?php echo $rlrpgSite->SafeDisplay('UserName') ?>' maxlength="255" /><br/>
    <span id='register_username_errorloc' class='error'></span>
</div>
<div class='container' style='height:80px;'>
    <label for='Password' >Password*:</label><br/>
    <div class='pwdwidgetdiv' id='thepwddiv' ></div>
    <noscript>
    <input type='password' name='Password' id='Password' maxlength="50" />
    </noscript>    
    <div id='register_password_errorloc' class='error' style='clear:both'></div>
</div>

<div class='container'>
    <input type='submit' name='Submit' value='Submit' />
</div>

</fieldset>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->

<script type='text/javascript'>
// <![CDATA[
    var pwdwidget = new PasswordWidget('thepwddiv','Password');
    pwdwidget.MakePWDWidget();

    var frmvalidator  = new Validator("register");
    frmvalidator.EnableOnPageErrorDisplay();
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("firstname","req","Please provide your name");

    frmvalidator.addValidation("lastname","req","Please provide your name");

    frmvalidator.addValidation("email","req","Please provide your email address");

    frmvalidator.addValidation("email","email","Please provide a valid email address");

    frmvalidator.addValidation("username","req","Please provide a username");

    frmvalidator.addValidation("Password","req","Please provide a password");

// ]]>
</script>

<!--
Form Code End (see html-form-guide.com for more info.)
-->

</body>
</html>

站点配置.php:

<?php
require_once('SiteViewModel.php');

$rlrpgSite = new siteviewmodel();

$rlrpgSite->SetWebsiteName('localhost.com');

$rlrpgSite->SetAdminEmail('rlrpg@localhost.com');

$rlrpgSite->SetRandomKey('Hng2XxIdNfp8EwO');
?>

站点视图模型.php:

<?php
class siteviewmodel
{
...
function siteviewmodel()
    {
        ob_start();
        fb("Instantiating");
        //This works
    }

RegistUser()
    {
        ob_start();
        fb("Registering");
        //doesn't work
    }
}
?>
4

0 回答 0