php 检查表是否存在_使用PHP检查功能和类是否存在

php 检查表是否存在

When you've inherited a big website or you're working on a group website where you don't have quick access to communicate with the other developers, it's important to not assume that a custom function or class name has not already been defined. Here's how you can protect yourself:

当您继承了一个大型网站或在无法快速与其他开发人员进行交流的小组网站上工作时,重要的是不要假设尚未定义自定义函数或类名。 保护自己的方法如下:

PHP (The PHP)


	
	if(!function_exists('show_article')) {
		function show_article($id) {
			//code here
		}
	}
	
	if(!class_exists('my_class')) {
		class myclass {
			//code here
		}
	}
	


Using this type of programming can also protect you in case a file gets accidentally included twice. If a file with a function definition were to be included twice, you'd get an ugly "redefined" error when the function is realistically only in one file.

如果文件被意外两次包含,使用这种类型的编程也可以保护您。 如果一个包含函数定义的文件要包含两次,那么实际上该函数仅存在于一个文件中时,您将收到一个难看的“重新定义”错误。

翻译自: https://davidwalsh.name/function-class-exists-php

php 检查表是否存在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值