echo
资深老生
资深老生
  • UID170
  • 粉丝0
  • 关注0
  • 发帖数4
  • 社区居民
阅读:1124回复:0

php魔鬼训练第三课作业

楼主#
更多 发布于:2016-07-14 15:34
godInit.php


<?php
/**
 * Created by PhpStorm.
 * User: muxiliu
 * Date: 7/13/16
 * Time: 11:44 PM
 */
  
class godInit{
    //define a static varible
    static $VERSION='god version is 1.1';
    static $pro_name='';    //define a varible for project name
    static $pro_author='';  //define a varible for project author
    static $pro_arr=array();
    //define a static function
    static function init(){
        echo 'what is you project name?'.PHP_EOL;
        self::$pro_name=fgets(STDIN); //STDIN是PHP中的標準輸入流,fgets是PHP中的獲取輸入,類似與C語言中的scanf
        echo 'what is you author name?'.PHP_EOL;
        self::$pro_author=fgets(STDIN);
  
        self::$pro_arr=array("name"=>self::$pro_name,"author"=>self::$pro_author);
//        echo '您輸入的信息是:'.PHP_EOL;
//        echo self::$pro_name;
//        echo self::$pro_author;
        return json_encode(self::$pro_arr);
    }
}
god_func7
<?php
  
function setConfig($cnt):string{
     return  file_put_contents(getcwd().'/god.json',$cnt).' bytes written.'.PHP_EOL.'god config is created.'.PHP_EOL;
}
god
#!/usr/local/php/bin/php
<?php
    //echo substr(PHP_VERSION,0,1);
    require('god_func'.substr(PHP_VERSION,0,1));
    require('godInit.php');
    $result='';
    if($argc>=2){
      '-v'==$argv[1] && $result=godInit::$VERSION.PHP_EOL;
      'init'==$argv[1] && $result=setConfig(godInit::init());
    }
    echo $result;

最新喜欢:

cctxercctxer
游客

返回顶部