Missing PHP String Functions: contains, equals, startsWith, endsWith

PHP is great because it is easy to deploy it on pretty much any webserver. But in my opinion the language itself is not very well designed. In this post I will take a look at the PHP string functions and offer implementations of those important string functions that PHP is missing (which are endsWith, startsWith, contains and equals). PHP and Java String functions compared: A Rant If you look at the Java String class it has all methods that one commonly needs for strings, and the method signatures are well designed.

Linux #4: Difference between find, locate and whereis

Difference between find, locate and whereis linux commands find: finds files by filename. see Linux: Search for a File by Filename for more details and example usages. locate: also finds files by filename but does not search the directory structure itself but only a database prepared by updatedb. Because of that locate is faster than find but less accurate. Examples: locate firefox # -> /etc/firefox # /etc/firefox-3.0 # /etc/firefox-3.5 # /etc/alternatives/firefox-homepage # /etc/alternatives/firefox-homepage-locales # [ .

Symfony2 Flash Message

Flash Messages make it possible to show a string on the next request, for example after a redirect. This is useful when you want to inform a user about the success or failure of form-requests. Symfony2 changed how flash messages work from version 2.0 to 2.1, so below you can read about how to use flash messages in both versions. Symfony2 flash message for Symfony 2.0 and below Setting the flash message To add a flash message – which lasts exactly one request – to a session use this code in the controller:

Domain Name Tools: Name suggestions, Price comparison and more

Here are a couple of tools that will help you choose and register a domain name: domain naming tipps: A list of things to consider when choosing a domain name. domain name suggestions generator: In case you need a good domain name idea this tool will generate a list of possible domain names on the basis of keywords provided by you and check if they are available. compare domain name prices: Compare the prices of the top domain name registrars and filter it by price, top level domain, available payment methods and by whether or not anonymous domain name registration is possible.

Linux #3: Search and Replace

Search and Replace text in one File To search a string in a file and replace all occurrences of it with a different string use sed: sed -i 's/string/replace/g' file With this command all occurrences of the text string in the file file will be replaced with replace. Search and Replace text in all Files in a directory To replace all occurrences of a string in all files in a directory recursively use sed in combination with find:

Low Adsense link unit coverage

My adsense link unit coverage is low. A lot lower than the coverage for the other adsense ad units so I tried to figure out what is going on. Google has this to say: For link units, coverage reflects the number of link units that showed ads after the user clicked on a term in the link unit. Coverage for pages displaying link units is typically much lower than for the other kinds of ad units, because it involves user clicking.

Netbeans: PHP autocomplete

In Netbeans PHP autocomplete does not always work because the type of a variable is not clear. Below you can read how to hint the type thus allowing for autocomplete to work in Netbeans with PHP as well as it does with Java.

WordPress: link image post to parent post

This post explains how to change the linking behavior of image posts for the WordPress default theme twenty eleven.

If you upload a gallery in WordPress and insert it in a post, each of these images will get their own post. In this post, only that image will be displayed (and some meta information) and if a user clicks on it the next image in the gallery will be displayed if you use the WordPress default theme twenty eleven.

And here is the problem: the user does not expect to be taken to the next image in the WordPress gallery. Most likely a user just came from a search engine and wants to read the post that belongs to the image (and you probably want the user to do just that as well).

Talk #4: Moving WordPress to production Server

Oftentimes it makes sense to set up and develop your WordPress page locally and then move it to a remote server once everything works. This prevents downtime of the live page in case something goes wrong, makes development easier and is just good practice in general. Here is a short description how to move WordPress from a local computer to the production server. Exporting and Importing WordPress Database and changing the website url # 1.

Talk #3: PHP – Comma Separated List from Array

After we discussed how to create a comma separated list in twig last week, this week I will show you how to do the same in plain PHP. Simple Comma Separated List in PHP without trailing comma The easiest way to get a String in PHP from the elements of an Array joined by some character is to use the implode function: $my_array = array('string1', 'string2', 'string3'); $comma_separated_list = implode(", ", $my_array); // $comma_separated_list now holds the value "string1, string2, string3" from the array $my_array As you can see, implode takes an array and returns a string containing its elements separated by a character of your choice which in this example is a comma.