The PHP function that I use the most could be str_replace(). If you aren't familiar with the function, here's what it does:
我使用最多PHP函数可能是str_replace() 。 如果您不熟悉此功能,请执行以下操作:
$string = 'Hello_My_Friend';
$result = str_replace('_', '-', $string); //becomes Hello-My-Friend
Over the past months, I've grown to realize that I oftentimes use the function as a quick fix. I've been using MySQL's version of str_replace() a lot lately in an effort to cleanse the sins of my programming past. Here's a basic usage of MySQL's REPLACE function:
在过去的几个月中,我逐渐意识到我经常使用该功能作为快速解决方案。 最近,我一直在使用MySQL的str_replace()版本,以消除我过去编程的过失。 这是MySQL的REPLACE函数的基本用法:
UPDATE website_content_pages SET content = REPLACE(content, 'b>', 'strong>');
The above code changes all <B>
and </B>
tags to <STRONG>
and </STRONG>
tags. Using MySQL's function allows me to fix the problem once instead of "re-fixing" it every time the page loads.
上面的代码将所有<B>
和</B>
标签更改为<STRONG>
和</STRONG>
标签。 使用MySQL的功能可以使我解决该问题一次,而不是每次页面加载时都“重新解决”它。