An example of the use of the php interface, with the phpstrom tool

The use of interfaces allows developers to develop less missing functional code

1 Create an interface file

game_interface.php

<?php
namespace Home\Tool;;
use Home\Tool;
/**
 * Created by PhpStorm.
 * User: smile
 * Date: 2018/1/4
 * Time: 20:36
 */
interface game_interface
{
    public static function caiji();
    public static function js();
    public static function save();
    public static function check_guize();
    public static function fanshui();
}

2. Create a class to inherit this interface

Game.class.php

<?php

namespace Home\Tool;;
use Home\Tool;

/**
 * Created by PhpStorm.
 * User: smile
 * Date: 2018/1/4
 * Time: 20:36
 */
abstract class Game implements game_interface{

}

3 Function class to inherit Game

Pk10.class.php

<?php

namespace Home\Tool;
use Home\Tool;

class Pk10 extends Game {
    public static $name ="北京赛车";
    public static function js()
    {
        // TODO: Implement js() method.
        caiji();
    }

    public static function caiji()
    {
        // TODO: Implement caiji() method.
    }

    public static function save()
    {
        // TODO: Implement save() method.
    }

    public static function check_guize()
    {
        // TODO: Implement check_guize() method.
    }


    public static function fanshui()
    {
        // TODO: Implement fanshui() method.
    }
}

The phpstrom tool is used when extending a class, and the code will be automatically generated, as shown above. If there is no method in the above code, it will prompt an error, move the mouse to the game, hold down the alt + enter keys, and automatically add

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326078386&siteId=291194637
Recommended