Posts Tagged Under PHP

December 4th, 2008

XInclude and XPointer – Advanced XML Part 2

This is the second part Advanced XML and PHP series. If you haven’t read first part you can find it here: Introduction to XPath in PHP. You may be not interested right now but unfortunately topic of todays article (XPointer and XInclude) are extensions of XPath, so it would be very helpful if you would go thru it right now, i assure you that XPath is very interesting technology and knowing it may benefit somewhere in the future.

Posted in PHP, XML
By Greg
read more
December 1st, 2008

PHP XPath Tutorial – Advanced XML Part 1

Few years back when i first read book about XML i could not understand what the hyip was all about, some markup language that allows to store data in well organized way. I also remember parsing XML files in PHP few years back. Whole file was raed using fread() and then programmer had to create some kind of parser to process XML file … completely ridicolous. Sure ActionScript, probably Java and some other languages as well already had classes for parsing XML files, but that was not the case for PHP, so i thought that this is a technology that do not deserve a second look.

Posted in XML
By Greg
read more
November 22nd, 2008

PHP Coding Standards

There is a lot of articles on the Internet about: becoming better programmer, writting better and more readable code, where someone just makes a list of techniques or tips (as they call it) that will make you a better programmer. In fact these articles are usually far from providing you with valuable information and most of the time can be summarized with two words – coding statndards.

Posted in General
By Greg
read more
November 13th, 2008

PHP AutoLoad Best Practices

Few days ago my friend Mark, added on my blog interesting comment regarding autoloading objects in PHP. While i think it is great to have quality comments like each of Mark’s comment, autoloading is a topic that requires a separate post.

What is autoloading? Every time you want to use a new class in your PHP project, first you need to include this class (using include or require language construct, that’s right this are not functions). However if you have __autoload function defined, inclusion will handle itself.

Posted in PHP
By Greg
read more
November 4th, 2008

PHP string to hex and hex to string functions

In my opinion SQL injection is an major issue when it comes to web application development. Typically programmers deal with it by escaping strings, while this is probably the best way to get it handled i want to show you different yet effective approach to this problem – converting string to hex value.

Posted in PHP
By Greg
read more
October 4th, 2008

PHP redirect header location

Ok finally i managed to write a new article after about a month ( actually i do not even want to think when i wrote last good article for you). Anyway today short article on using headers to redirect vistors to other pages on your site or external site.

To do this you need only one function
header($header, $replace, $http_response_code);

First argument $header is a header itself. We want to use header to redirect visitors so in our case we will use something like “Location: URL” where URL is obviously an url of a page to which you want to redirect visitor. It can be full url (http://some-random-url.com/pages/page.html) or relative URL (pages/page.html)

Posted in PHP
By Greg
read more
September 21st, 2008

Developing Webbots, Spiders and Screen Scrapers with PHP cURL

For a long time i wanted to write detailed tutorial on how to use PHP and cURL to create bots and i am still going to do that, but while browsing Amazon i found very interesting book related to this topic A Guide to Developing Internet Agents with PHP/CURL written by Mike Schrenk. I did not read this book yet, but it looks very promising and interesting … atleast to me, because it is not yet-another-php-for-beginners, but a book that focuses and deeply explores one single topic – creating webbots.

In my opinion knowing how to create web bots is one of the most important web programmer skills, there is so much data on the internet that we need bots to take full adventage of the resources on the web and automate day to day boring online tasks. More over you will be surprised how often you will be asked on job interview if you can write a webbot.

Posted in Reviews
By Greg
read more
July 30th, 2008

Clone keyword in PHP

A lot of people do not read PHP manual. That is a fact, they will look for answers to their questions on forums, books, blogs (like this one for example) and so on, while most of the answers they are looking for, are already there … in PHP manual. Or maybe it is me who is weired, because i like to browse PHP.net to see “what’s new”, well can’t really tell.

Posted in PHP
By Greg
read more
July 17th, 2008

PHP, JSON and JavaScript usage

Today i want to introduce you to jSON (JavaScript Object Notation), in short, it is a simple format designed to exchange data between different programming languages. I will show you how to create JavaScript object, convert it to JSON string, and send to PHP script, which will decode jSON string to readable format (for PHP). But that’s not all, PHP script will create it’s own data object encode it to jSON string and send it back. All communication between JavaScript and PHP will be done thru AJAX.

Posted in Ajax, PHP
By Greg
read more
June 29th, 2008

Clean input variable PHP

Some time ago i wrote a post about query string and i think i pretty well covered that topic, however i didn’t mentioned one thing … cleaning input variables. In fact it is much more important to know how to clean $_POST and $_GET arrays then know how to handle query string, because variables sent by user are the only way to hack your script, it is that simple, if you take care of input variables then your script is 100% safe.

Posted in PHP
By Greg
read more