最新消息:博客的意义不在于数量,在于原创。

7个鲜为人知却超实用的PHP函数

PHP 辰 羽 7707浏览 0评论

PHP有许多内置函数,其中大多数函数都被程序员广泛使用。但也有一些函数隐藏在角落,本文将向大家介绍7个鲜为人知,但用处非常大的函数。 没用过的程序员不妨过来看看。

1.highlight_string()

当需要在一个网站中展示PHP代码时,highlight_string()函数就变的非常有用了。该函数通过使用PHP语法高亮程序中定义的颜色,输出或返回给定的PHP代码的语法高亮版本。

2.str_word_count()

该函数必须要传递一个参数,根据参数类型返回单词的个数。如下面的所示:

3.levenshtein()

该函数主要返回两个字符串之间的Levenshtein距离。Levenshtein 距离,又称编辑距离,指的是两个字符串之间,由一个转换成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。该函数对查找用户所提交的错别字非常有用。

4.get_defined_vars()

该函数返回一个包含所有已定义变量列表的多维数组,这些变量包括环境变量、服务器变量和用户定义的变量。

5.escapeshellcmd()

该函数用来避开字符串中的特殊符号,可以防止使用者耍花招来破解服务器系统。可以用本函数搭配exec() 或是system() 二个函数,这样可以减少网上使用者的恶意破坏行为。

6.checkdate()

本函数可以用来检查日期是否有效,例如年为0至32767年、月为1至12月、日则随着月份及闰年变化。

7.php_strip_whitespace()

该函数可以返回已删除PHP注释以及空白字符的源代码文件,这对实际代码数量和注释数量的对比很有用。

转载自:http://www.csdn.net/article/2013-12-10/2817756-PHP

 

转载请注明:辰羽的视界 » 7个鲜为人知却超实用的PHP函数

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (13)

  1. I must admit that this is one great insight. It surely gives a company the opportunity to get in on the ground floor and really take part in creating something special and tailored to their needs.
  2. this is a very interesting dispatch, acknowledgement you for the benefit of the information. Contrite my english is not the sheer best. do you be versed if it is tenable to despatch this to the spanish language. that would be quite helpfull.
  3. is among the. these days I dont knowledgeable in.
    Oakley Wallet Canada4年前 (2015-04-14)回复
  4. I like this internet website quite significantly, Its a truly nice billet to read and obtain information .
  5. As I web site owner I believe the content material here is quite superb, thanks for your efforts.
    Nike Free Run 2 Sizing4年前 (2015-04-17)回复
  6. Please tell me that youre heading to keep this up! Its so great and so important. I cant wait to read more from you. I just really feel like you know so considerably and know how to make people listen to what youve to say. This weblog is just also cool to become missed. Terrific stuff, actually. Please, PLEASE keep it up!
  7. Greetings everyone, This webpage is terrific and so is how the matter was expanded. I like some of the comments as well although I would prefer we all maintain it on topic in order add value to the subject.
  8. Very good post. I just stumbled upon your weblog and wanted to say that I have truly enjoyed surfing about your blog posts. After all I will be subscribing to your rss feed and I hope you write once more soon!
    Discount Oakley Goggles4年前 (2015-04-21)回复
  9. I have to admit this content was very worthwhile. I discovered you with a google search and was rather stunned at your rank for this article.
  10. This blog site has got lots of very helpful information on it! Thanks for sharing it with me.
  11. Heya i am for the first time here. I found this board and I find It truly useful & it helped me out a lot. I hope to give something back and help others like you helped me.
  12. Thank you pertaining to giving this excellent content on your web-site. I discovered it on google. I may check back again if you publish extra aricles.
    Tyler Oakley Website4年前 (2015-04-23)回复
  13. how goes it I valued your grand, weblog