PHP的解析没有文件;只是返回code [英] php not parsing file; Just returns code

查看:195
本文介绍了PHP的解析没有文件;只是返回code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的地方显然类没有被正确解析的问题,而所有的文件似乎是在正确的地方。

I have got a problem where my class apparently is not being parsed correctly and the all files appear to be in place correctly.

下面是我的层次结构:

|
|_'_includes'
|__classes
|___class.login.php
|___class.fmdb.php
|__'fm_api'
|___FileMaker.php
|
|_'public_html'
|__login.php

(我希望是有道理的 - 封装在引号中的是文件夹)

(I hope that makes sense - the ones encapsulated in quotes are the folders)

我的问题是,显然我的code未得到正确解析,浏览器只是显示这个类code。

My problem is that apparently my code is not getting parsed correctly and the browser is just showing the class code.

下面是我的两个班,其中达到:

Here are my two classes where it reaches:

class.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();
    }
}

class.fmdb.php:

class.fmdb.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();
    }
}

?>

这是当我打电话的功能得到什么返回:

And this is what gets returned when I call the functions:

有关,由于其性质的原因,有些这是机密,我不能告诉你所有的code,但为什么这可能会发生的事情将是一个很大的帮助的任何建议!

For reasons that some of this is confidential due to its nature I cannot show you all of the code, but any suggestions on why this may be happening would be a great help!

谢谢!

抱歉,code口显示只有每个类的片段。我不能发布完整的类code,因为它是一个与工作相关的项目。

Sorry, the code I show are only snippets of each class. I cannot post the full class code as it is a work-related project.

推荐答案

你有没有结束PHP的标记? ?>,虽然它是可选的它可能是必要的,因为你包括其它文件。

you have no closing php tag? ?>, although it's optional it might be necessary since your including other files.

这篇关于PHP的解析没有文件;只是返回code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆