Let me introduce to you an application example of StarCraft in PHP memo mode. I hope the example can help you. When we play StarCraft version or stand-alone against the computer, sometimes we will suddenly leave the game, or Before sending troops, you need to save the game. Create a class specifically to save information and let it handle these things, just like a memo. For simplicity, we will demonstrate here by restoring a player's information.
The first step is to download a very practical PHP memo mode class that we need to use in this course: http://www.php.cn/xiazai/leiku/591
The second step, after the download is completed, find the php class file we need, unzip it to our local directory, and create a new php file!
The third step, after completion, we need to call this class in the new php file and instantiate the class:
<?php include_once "mobile.php";//引入类文件 //制造一个玩家 $p1 = new Player(); //假设他现在采了100水晶矿 $p1->ore = 100; //我们先保存游戏,然后继续玩游戏 $m = $p1->getMemento(); //假设他现在采了200水晶矿 $p1->ore = 200; //我们现在载入原来保存的游戏 $p1->restore($m); //输出水晶矿,可以看到已经变成原来保存的状态了 echo $p1->ore;
Run the file, and the result will be as shown below:
The above is the detailed content of Development example sharing of php memo mode. For more information, please follow other related articles on the PHP Chinese website!