php不解析文件;只返回代码

php不解析文件;只返回代码,php,apache,oop,parsing,Php,Apache,Oop,Parsing,我遇到了一个问题,我的类显然没有被正确解析,并且所有文件似乎都正确就位 以下是我的层次结构: | |_'_includes' |__classes |___class.login.php |___class.fmdb.php |__'fm_api' |___FileMaker.php | |_'public_html' |__login.php (我希望这是有意义的——用引号括起来的是文件夹) 我的问题是,显然我的代码没有得到正确的解析,浏览器只是显示类代码 以下是我的两个课程: class.

我遇到了一个问题,我的类显然没有被正确解析,并且所有文件似乎都正确就位

以下是我的层次结构:

|
|_'_includes'
|__classes
|___class.login.php
|___class.fmdb.php
|__'fm_api'
|___FileMaker.php
|
|_'public_html'
|__login.php
(我希望这是有意义的——用引号括起来的是文件夹)


我的问题是,显然我的代码没有得到正确的解析,浏览器只是显示类代码

以下是我的两个课程:

class.login.php:

<?php

require_once ('config/config.constants.php');
require_once ('classes/class.fmdb.php');
/**
 * Performs all the Login actions
 *
 * @author RichardC
 */
class Login {

    protected $fm;
    protected $fmdb;

    public function __construct() {
        $this->fm = new FileMaker(constant('FMDB_NAME'), constant('FMDB_IP'), constant('FMDB_USERNAME'), constant('FMDB_PASSWORD'));
        $this->fmdb = new FMDB();
    }
}

这就是我调用函数时返回的结果:

由于某些原因,由于它的性质,我不能向您展示所有的代码,但是任何关于为什么会发生这种情况的建议都会有很大的帮助

谢谢

[编辑]


抱歉,我显示的代码只是每个类的片段。我无法发布完整的类代码,因为它是一个与工作相关的项目。

您没有结束php标记??>,虽然它是可选的,但可能是必需的,因为您的Web服务器包含了其他文件。

您的Web服务器是否将该文件解释为PHP?并非所有服务器都是由defalut设置的,您有时需要通过.htaccess自己进行设置(假设您使用的是apache)


“只是显示类代码”哪个类?FileMaker.php中的文本逐字显示?是否缺少一个
@Viruzzo:它显示class.fmdb中的文本。php@jprofitt:这只是代码的一小部分,对不起,我没有说清楚。这段代码一直都是这样做的,还是在你移动到另一台机器后开始发生的?嗯?据我所知,结束PHP标记从来都不是必需的(同样,糟糕的风格)。结束PHP标记应该一直存在。如果它不在那里,那是非常糟糕的做法。事实上,它可能会导致一些错误。从包含()的PHP手册中可以看出:“当包含一个文件时,解析会在目标文件的开头退出PHP模式并进入HTML模式,然后在结尾再次恢复。因此,目标文件中应作为PHP代码执行的任何代码都必须包含在有效的PHP开始和结束标记中。”另一个选择是尝试暂时删除所有评论。它们可能会导致问题。另一个原因可能是某个包含文件或主文件中缺少开始标记。正在编写的代码在哪里,是否未包含在代码片段中?我已经尝试过,但没有成功,我的Web服务器设置为插入PHP文件。无论如何,谢谢你的建议!你验证过php的版本了吗?我认为这无关紧要,但这是可能的。
<?php

require_once ('fm_api/FileMaker.php');
/**
 * Database interface for the Scheduler
 *
 * @author RichardC
 */
class FMDB {

    /**
     * Setting the class-wide variables
     */
    protected $fm;
    protected $layout = '';
    protected $records = array();

    public $lastObj = null;


    /**
     * The constructor of the class
     */
    public function __construct() {
        $this->fm = new FileMaker(FMDB_NAME, FMDB_IP, FMDB_USERNAME, FMDB_PASSWORD);
    }

    /**
     * Returns an Error if there is one, for example: error 401 (record missing)
     * 
     * @author  RichardC 
     * @since   1.0
     * 
     * @version 2.0
     * 
     * @param obj    $request_object
     * 
     * @return int (error Code || 0 on no error)
     */
    public static function isError($request_object) {
        //The reason it returns 0 instead of false is due to the getCode() method, which will return the original error code so you can check if isError( $res ) > 0
        return (FileMaker::isError($request_object) ? $request_object->getCode() : 0);
    }

    /**
     * Selects data from a FileMaker Database
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string    $layout
     * @param array     $arrSearchCriteria
     * @param bool      $recordId (true to get the Record ID or false to ignore)
     * 
     * @example $objScheduler->select('someLayout', array( 'FieldName'  =>  'Value' ), true);
     * 
     * @return array
     */
    public function select($layout, $arrSearchCriteria) {

        $arrOut = array();

        if ((!is_array($arrSearchCriteria))) {
            return false;
        }

        $findReq = $this->fm->newFindCommand($layout);

        foreach ($arrSearchCriteria as $field => $value) {
            $findReq->addFindCriterion($field, $value);
        }

        $results = $findReq->execute();

        //Checks for an error
        if ($this->isError($results) === 0) {
            $records = $results->getRecords();

            //Set the last layout used
            $this->layout = $layout;
            $this->lastObj = $records;

            foreach ($records as $record) {

                $arrOut[] = $record;

                foreach ($record->getFields() as $field) {
                    $this->records[] = $field;
                }
            }
        } else {
            $arrOut['errorCode'] = $this->isError($results);
        }

        return $arrOut;
    }

    /**
     * Secures a string using mysql_real_escape_string and htmlentities
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string $string
     * 
     * @return string
     */
    public function fm_escape_string($string) {
        return mysql_real_escape_string(htmlentities($string));
    }

    /**
     * Get the records returned by the Select in an array
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @return  array
     */
    public function getRecords() {
        return $this->records;
    }

    /**
     * Set fields by in the Layout with the given fields and values
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.2
     * 
     * @param array     $arrFields 
     * 
     * @note    If you want to specify a layout, please use the update function.
     * 
     * @return  boolean
     */
    public function setFields($arrFields) {

        $blOut = false;

        if ((!is_array($arrFields))) {
            return false;
        }

        $layout = (empty($layout) ? ($this->layout) : ($layout));
        $records = $this->lastObj;

        // The record object is already initialised
        if (isset($records) && !empty($records)) {

            foreach ($records as $record) {
                foreach ($arrFields as $fieldName => $value) {

                    $setFields[] = $record->setField($fieldName, $value);
                }
            }

            $commit = $record->commit();

            if ($this->isError($commit) === 0) {
                $blOut = true;
            } else {
                return $this->isError($commit);
            }
        }

        //Speed things up
        unset($record, $commit, $fieldName, $value);

        return $blOut;
    }


    /**
     * Update the fields on a layout with specified data
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param   string  $layout
     * @param   array   $arrFields
     * @param   int     $iRecordID
     * 
     * @example $objFM->update('exampleLayout', array('Field1' => 'This is the data which Field1 will be updated with'), 1);
     * 
     * @return  boolean
     */
    public function updateRecordByID($layout, $arrFields, $iRecordID) {
        $blOut = false;

        if (($layout == '') || (!is_array($arrFields)) || (!is_number($iRecordID))) {
            return false;
        }

        $findReq = $this->fm->newFindCommand($layout);

        //Loops through setting the where clause
        foreach ($where as $field => $value) {
            $findReq->addFindCriterion($field, '==' . $value);
        }

        $result = $findReq->execute();

        //Checks for errors
        if ($this->isError($result) === 0) {
            $result = $this->fm->getRecordById($layout, $iRecordID);

            //Loops through each result from the 'Select'
            foreach ($records as $record) {
                //Loops through all given fields and values, setting the fields to be said values
                foreach ($arrRecords as $f => $v) {
                    $record->setField($f, $v);
                }
                $commit = $record->commit();
            }
            //Checking for errors
            if ($this->isError($commit) === 0) {
                $blOut = true;
            } else {
                return $this->isError($commit);
            }
        } else {
            return $this->isError($result);
        }

        // Speed things up
        unset($result, $commit, $record, $findReq);

        return $blOut;
    }

    /**
     * Inserts a record into the Table/Layout with the given data from $arrFields
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param string $layout
     * @param array  $arrFields
     * 
     * @return boolean 
     */
    public function insert($layout, $arrFields) {

        $blOut = false;

        if (($layout == '') || (!is_array($arrFields))) {
            return false;
        }

        $addCmd = $this->fm->newAddCommand($layout, $arrFields);
        $result = $addCmd->commit();

        if ($this->isError($result) === 0) {
            $blOut = true;
        } else {
            return $this->isError($result);
        }

        //Speed things up
        unset($addCmd, $result);

        return $blOut;
    }

    /**
     * List Layout Names from Database
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @return array
     */
    public function get_layout_names() {
        return $this->fm->listLayouts();
    }

    /**
     * Alias of the select function
     *
     * @author RichardC
     * @since  1.0
     * 
     * @version 1.0
     * 
     * @param string $layout
     * @param array  $arrSearchCriteria
     * 
     * @return array
     */
    public function find($layout, $arrSearchCriteria) {
        return $this->select($layout, $arrSearchCriteria);
    }

    /**
     * Returns the number of rows in a given query
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     * 
     * @param array $arrResult
     * 
     * @return int 
     */
    public function fm_num_rows($arrResult) {
        return (!is_array($arrResult) ? 0 : count($arrResult));
    }


    /**
     * Runs a script on the server from the web
     * 
     * @author  RichardC
     * @since   1.0
     * 
     * @version 1.0
     *
     * @param string $layout
     * @param string $scriptName 
     * @param array  $params (Optional depending on the script params that you wish to execute)
     * 
     * return boolean
     */
    public function runScript($layout, $scriptName, $params = array()) {
        $blOut = false;

        if ((empty($layout)) || (empty($scriptName))) {
            return $blOut;
        }

        if ($this->fm->newPerformScriptCommand($layout, $scriptName, $params)) {
            $blOut = true;
        }

        return $blOut;
    }

    /**
     * Rec-ID (FileMaker Record ID hidden field)
     * 
     * LayoutName, Field Value, FieldName
     */
    public function getLastID() {

    }

    public function delete($layout, $iRecordID) {
        // Example from $this->update :: $result = $this->fm->getRecordById($layout, $iRecordID);
    }

    /**
     * Gets the record ID from the current record
     *
     * @author  RichardC
     * @since   1.0
     * 
     * @return int 
     */

    public function getRecordId() {
        return $this->lastObj->getRecordId();
    }
}

?>
AddType application/x-httpd-php .php .php5 .phtml