background preloader

43 Must Read PHP Articles and Resources

43 Must Read PHP Articles and Resources

Still life: Bent objects » Article » OWNI.eu, Digital Journalism UPDATE: The Return of Bent Objects Wires transform these objects from inanimate to hilarious works of art. Little polish girl McDonalds as Sculpture Materials Yeah, this is where those come from Dancing Queens English breakfast Sylvia Muffin put her head in the oven. The introvert Bananas in bed – let’s slip into bed together You Say Tomato, I Say Tomahto. Fruit with life experience Zombies are nuts about brains Modest pear Literary interpretations Paper training our little dog, Frank A little cat doodle Photo Credits: Terry Border at Bent Objects View more In Pictures sets on Owni.eu What's the Right Way to Prevent SQL Injection in PHP Scripts? - Brian Swan How to prevent SQL injection in PHP scripts is probably a topic that doesn’t need anything more written about it. It is pretty easy to find blog posts, documentation, videos, etc. that explain the importance of preventing SQL injection and suggestions for preventing it. In fact, I’ve already written a post on this topic as a guest writer on the SQL Server Driver for PHP team blog. However, it is important to have fresh information for new Web developers and I don’t necessarily agree with some of the most common suggestions for preventing SQL injection. SQL injection (or a SQL injection attack) occurs when a user provides SQL code as user input for a Web page, and the SQL code is then executed in the database. <form method="post" action="injection.php" enctype="multipart/form-data" > Username:<input type="text" name="Username" id="Username"/></br> Password:<input type="text" name="Password" id="Password"/></br> <input type="submit" name="submit" value="Submit" /> </form> <? Thanks.

15 very useful PHP code snippets for PHP developers | ViralPatel.net Following are list of 15 most useful PHP code snippets that a PHP developer will need at any point in his career. Few of the snippets are shared from my projects and few are taken from useful php websites from internet. You may also want to comment on any of the code or also you can share your code snippet through comment section if you think it may be useful for others. 1. 2. 3. The above code will not work in case your client is behind proxy server. 4. This function will return the duration of the given time period in days, hours, minutes and seconds. e.g. secsToStr(1234567) would return “14 days, 6 hours, 56 minutes, 7 seconds” 5. 6. Required Extension: SimpleXML 7. 8. Following is the PHP code to create the JSON data format of above example using array of PHP. Following code will parse the JSON data into PHP arrays. 9. 10. This basic snippet will create a random authentication code, or just a random string. 11. Validate a date in “YYYY-MM-DD” format. 12. 13. 14. 15.

Object passing (with and without serialization) in php - This article will show you how to handle in a proper way a very common situation: a user logs in your site and you want to keep trace of his details while he browses around your site using just one Imagine you have done a site (an e-commerce one e.g.) and you have a nice login page. Your users will insert their username and password and if the data they insert is correct, they are redirected e.g. to the catalog page where they can buy your products. Many of us do this almost everyday buying stuff from many different sites. Ok, how would you handle variable passing? It can be done in many ways. Probably a php noobie would just verify if username and password are correct and then would retrieve data from the database, storing each data in a session var (or a cookie, it's the same for the purpose of this article) and then retrieving them when needed. // we have surely remembered to put // session_start(); // at the beginning of our .php page // process user input here if (user has inserted correct vals) { // retrieve firstname, lastname, id, username from database and store them // retrieving code here $rs=mysql_fetch_array($qry); Nice huh? Very simple class. <body> <p> <? ?

8 Best Open Source Shopping Carts Hey Everyone, On Sunday I was contacted by a client and they said the needed a shopping cart up by Monday. Since they needed this cart up so fast I went to the easiest solution I knew, Open Source Shopping Carts. I browsed through tons of shopping carts and put together a list of only the best carts. is robust, professional grade e-Commerce shopping cart that you can download, install, and use for free. is a powerful, free PHP/MySQL shopping cart system that is easy to install and customize. Tags: e-commerce, mySql, Open Source, perl, PHP, shopping carts

Deciphering Magic Methods in PHP PHP provides a number of 'magic' methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met. Magic methods provide some extremely useful functionality, and this tutorial will demonstrate each method's use. Before We Begin In order to fully understand magic methods, it's helpful to see them in action. If words like "method" and "property" sound alien to you, you might want to read up on this first. Device objects will hold a name, a Battery object, an array of data, and a handle to some external resource. This tutorial assumes you have a basic understanding of object oriented programming. These classes are pretty useless, but they make a good example for each of the magic methods. Constructors & Destructors Constructors and destructors are called when an object is created and destroyed, respectively. __construct() __get()

Related: