PHP

DOMNodeList as an Array

Sunday, August 31st, 2008

When using getElementsByTagName, it returns a DOMNodeList which you can use with foreach, but you can’t use array indexes to access elements. For example, you can use the following code to the contents of the first “test” tag: <?php $file = ‘z.xml’;$xmlfile = new DOMDocument(); @$xmlfile->load($file); $iplist =$xmlfile->getElementsByTagName(‘test’); $i = 0; foreach($iplist as \$v) { […]

The “Gtk-CRITICAL gtk_text_buffer_emit_insert assertion” warning in PHP-GTK2

Saturday, August 30th, 2008

If your internationalized PHP-GTK2 apps have ever failed to work, you probably received the following message in the terminal before: Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)’ failed This means that you have been using or passing non-UTF8 (good chance that it is CP1252 on Windows) strings to PHP-GTK2 classes and methods, such as […]

Changing the user agent of PHP

Wednesday, August 20th, 2008

If you ever need to adjust or change the default user agent that PHP accesses pages with (http and ftp wrappers) because either the default PHP user agent was blocked (“PHP”) or you wrote a bot with PHP and wish to customize it, you can do so easily with a php directive called “user_agent”. Note […]

Using UTF-8 in PHP-GTK2

Monday, August 18th, 2008

When trying to use a string that has characters that are non-English (Asian and middle east characters) or characters that have accents for PHP-GTK’s widgets, you may possibly encounter a situation like the image to the right. This bug or glitch is caused by the fact that you are trying to use a regional encoding […]

Sunday, August 17th, 2008

For those of you who have never heard of it, a GtkAboutDialog is a convience GtkDialog to display application credits. However, the documentation (archive at 2008-08-17) for it does not specify a way to change the application’s name, and as a result ends up using the script name for the application, which is very ugly […]

Stopping the “PHP Fatal error: Internal object missing in” error in PHP-GTK2

Saturday, August 16th, 2008

In PHP-GTK2, if you build your own class of an existing PHP-GTK2 class, you may encounter one of the following errors: “PHP Fatal error:  Internal object missing in YourclassName wrapper in /path/to/your/script on line *” “Fatal error: Internal object missing in YourclassName wrapper in /path/to/your/script on line *” This is somehow (not documented) caused by […]

Embeder – a free PHP to EXE solution

Friday, August 15th, 2008

If you’re looking for a PHP to EXE solution that supports PHP5, Embeder is one rarely mentioned application that will convert your PHP applications into a Windows executable file, although it will only work with PHP 5.0.3. Below are the steps to set it up on your system. (Will run under Linux with Wine, too.) […]

Parsing text files in PHP with FlatfileTools

Wednesday, August 13th, 2008

Compdigitec FlatfileTools is a API written in PHP to manipulate, read and modify plain text databases. It can also manipulate existing databases, such as CSV files. It is released under the GNU General Public License and therefore is free software. To use it, download Compdigitec FlatfileTools. Then include_once it like this: <?php include_once(‘flatfiletools.lib.php’); // The rest of your code goes here… ?> […]

Install bcompiler for PHP on Ubuntu Linux

Sunday, August 10th, 2008

The PHP bytecode compiler is a useful way to convert PHP to bytecode, which can then be converted to binaries. However, the Ubuntu packaging team has not yet made a binary package of bcompiler available. However, you can install this bytecode compiler yourself with these 9 easy to follow steps. A binary build is availible, […]

Simple way to read bzip2 compressed files in PHP

Saturday, August 9th, 2008

If you are looking for a way to read quick way to read a compressed bzip2 file’s contents, look no further. We have made a function that works similar to the way file_get_contents works. The code is released under the GPL v2 or later license.

« Previous Entries Next Entries »