php示例代码
来源:互联网 发布:甲基异噻唑啉酮 知乎 编辑:程序博客网 时间:2024/06/06 10:07
1、面向过程代码示例
<?phpif($animal=="dog"){ if($animal=="dog"){ return "汪";} if($animal=="cat"){return "喵";} if($animal=="cow"){ return "哞"; } return "暂时听不懂该动物的声音,动物学家们正在研究"; } echo getSound("dog");//汪 echo getSound("cat");//喵 echo getSound("cow");//哞 ?>
2、面向对象的示例代码
<?php function getSound($animal){ if($animal instanceof Animal){ return $animal->showSound(); } return "暂时听不懂该动物的声音,动物学家们正在研究"; } class Animal{ function showSound(){ return "不同动物应该用不同声音"; } }class Dog extends Animal{function showSound(){return "汪"; }}class Cat extends Animal{function showSound(){ return "喵";}}class Cow extends Animal{ function showSound(){ return "哞"; } } $dog=new Dog(); echo getSound($dog);//汪 $cat=new Cat(); echo getSound($cat);//喵 $cow=new Cow(); echo getSound($cow);//哞?>
}
1 0
- php示例代码
- rabbitmq PHP代码示例
- PHP SOAP服务示例代码
- 一个php日历示例代码
- php分页函数示例代码
- php+mysql分页代码示例
- PHP函数柯里化代码示例
- PHP操作xml示例代码
- PHP操作xml示例代码
- php curl https代码示例
- php操作mysqli(示例代码)
- 一段简单的php分页代码示例
- PHP分页技术的代码和示例
- PHP分页技术的代码和示例
- PHP分页技术的代码和示例
- PHP分页技术的代码和示例
- php指定函数参数默认值示例代码
- php自定义的格式化时间示例代码
- TensorFlow GPU环境linux搭建指南
- 算法时间复杂度&空间复杂度
- 深入探寻seajs的模块化与加载方式
- Servlet监听器(Listener)
- Dll 文件导出方式,Debug/Release简要区别
- php示例代码
- ubuntu SecureCRT 安装破解
- 非递归快速幂算法
- javaSE异常处理方式浅谈--拙见
- 找不到该项目,请确认该项目的位置的办法
- 【android】Android的消息机制
- linux查看日志文件内容
- docker+rails+postgresql+redis+puma+nginx
- Cookie/Session机制详解