Giter VIP home page Giter VIP logo

create-your-own-php-framework's Introduction

Hi there 👋

Anurag's github stats

create-your-own-php-framework's People

Contributors

craryprimitiveman avatar faithpatrick avatar wujunze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-your-own-php-framework's Issues

写的挺好的。

十二章,Compiler类中

public function compile($file = null, $params = [])
{
$path = '../views/'.$file.'.sf';
extract($params);
if (!$this->isExpired($path)) {
$compiled = $this->getCompiledPath($path);
require_once $compiled;

          return;
      }   
      $fileContent = file_get_contents($path);
      $result = ''; 
      foreach (token_get_all($fileContent) as $token) {
          if (is_array($token)) {
              list($id, $content) = $token;
              if ($id == T_INLINE_HTML) {
                  foreach ($this->compilers as $type) {
                      $content = $this->{"compile{$type}"}($content); //这个是不是改成拼接呢 $content .= $this->{"compile{$type}"}($content); 
                  }   
              }   
              $result .= $content;
          } else {
              $result .= $token;
          }   
      }   
      $compiled = $this->getCompiledPath($path);
      file_put_contents($compiled, $result);
      require_once $compiled;
  }   

public/index.php -> call_user_func err~!

Deprecated: Non-static method app\controllers\SiteController::Test() should not be called statically in E:\simple-work\public\index.php on line 10
test is success~!

求教一个问题

在第五章节中,

  public static $pdo;

    /**
     * Get pdo instance
     * @return PDO
     */
    public static function getDb()
    {
        if (empty(static::$pdo)) {
            $host = 'localhost';
            $database = 'sf';
            $username = 'jun';
            $password = 'jun';
            static::$pdo = new PDO("mysql:host=$host;dbname=$database", $username, $password);
            static::$pdo->exec("set names 'utf8'");
        }

        return static::$pdo;
    }

这里用static变量可以保证所有继承该Model的类用的都是同一个PDO实例,getDb方法实现了单例模式。

我疑问是为什么不使用self::$pdo呢?
我是这样理解的:
因为子类中没有复写$pdo,所以static::$pdo使用的一直是父类的$pdo。
self::$pdo也是可以实现单例模式的啊,因为它始终用的也是父类中的$pdo。

请问我这样理解的对吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.