Archive for the ‘PHP’ Category

PHP Tutorial: A Quick Way to Break up a URL into usable Pieces

PHP has a built in function which allows for the quick breaking up of a well formed URL into usable pieces, namely parse_url. This function parses a URL and returns an associative array containing any of the various components of the URL that are present. It is important to note that parse_url does not validate [...]

PHP: Remove Last Character from String – substr/substr_replace/rtrim

 This is a very common PHP question, how to remove last character from string in PHP? So here are three ways how to delete last character from string in PHP.   Incoming search terms:how to remove last character from string in php (1)last command remove in string php (1)replace last character in string php (1)replace [...]

PHP Memory Usage Information Class

Sometimes it’s nice to know or even very important to know, how much your PHP script is using memory. This is a simple example of a class, which can be used to collect the PHP script memory usage information and to print all information. It’s easy to reformat output, if you want to use it [...]

How to Resolve Fatal Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes)

Recently, when either adding new plugins or upgrading plugins in WordPress, I encountered this error message: Fatal Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes)… This means that WordPress needs more memory to run a process than the default PHP setting (usually 12M, in some, 32M). For a non-techie guy [...]

File Rename or Move on the server – PHP Code

Server-side files move or rename via php adds more flexibility to some applications. A common scenario when working with files involves creating a temporary file through uploading or other means and then renaming this file to a permanent location. This recipe describes changing the name of an existing file using the PHP function rename(). The [...]

Camel Case to Spaces or Underscore – PHP Code

Most of the php development project, I need to convert camelcase strings to space-separated strings. Recently while working on a project, I found I needed to convert camelcase strings to underscore separation. Camel case is frequently used in programming and data storage. Here are a couple of ways to convert it. As usual, feel free [...]

PHP: Let Your Properties be Properties

There is a coding pattern that I see (and have used) in PHP code that defines generic methods on a class for setting and getting properties. function set($name, $value); function get($name); Google code search for examples Some times there are some ancillary methods to deal with unsetting, checking for existence, setting via an array, or [...]

Benchmarking PHP’s Magic Methods

Larry Garfield has an interesting set of benchmarks covering many of PHP’s magic methods. His results correspond pretty well to my own benchmarks in the area. The thing to take away is that its not necessarily the overhead of the magic methods, but rather what you do inside them. Its hard to do anything useful [...]

Powered by WordPress | Designed by: best suv | Thanks to trucks, infiniti suv and toyota suv