background preloader

AtomicPHP.com - Free PHP Scripts, Large PHP script directory site

AtomicPHP.com - Free PHP Scripts, Large PHP script directory site

Create daemons in PHP Everyone knows PHP can be used to create websites. But it can also be used to create desktop applications and commandline tools. And now with a class called System_Daemon, you can even create daemons using nothing but PHP. And did I mention it was easy? Update 4 Dec, 2012: Legacy Warning This class was relevant in 2009, and may still be to some people, but if you want to daemonize a php script nowadays, a 5-line Ubuntu upstart script should suffice. If you're still convinced you need to do this with pure PHP, read on. What is a Daemon? A daemon is a Linux program that run in the background, just like a 'Service' on Windows. You reading this page, would not have been possible without them. Why PHP? Most daemons are written in C. Reuse & connect existing code Think of database connections, classes that create customers from your CRM, etc.Deliver new applications very fast PHP has a lot of build in functions that speed up development greatly.Everyone knows PHP (right?) Possible use cases Beta

PHPBuilder.com, the best resource for PHP tutorials, templates, PHP manuals, content management systems, scripts, classes and more. I wish I had known these 10 tips the day I started working with PHP. Instead of learning them through painstaking process, I could have been on my way to becoming a PHP programmer even sooner! This article is presented in two parts and is intended for folks who are new to PHP. Tip 1: MySQL Connection Class The majority of web applications I've worked with over the past year have used some variation of this connection class: class DB { function DB() { $this->host = "localhost"; // your host $this->db = "myDatabase"; // your database $this->user = "root"; // your username $this->pass = "mysql"; // your password $this->link = mysql_connect($this->host, $this->user, $this->pass); mysql_select_db($this->db); } } // calls it to action $db = new $DB; Simply edit the variables and include this in your files. $result = mysql_query("SELECT * FROM table ORDER BY id ASC LIMIT 0,10"); More information can be found in the manual--be sure you read the comments:

PHP for Beginners: Building Your First Simple CMS The Magic of PHP + MySQL It’s safe to say that nearly every website that’s up-to-date these days is using some form of content management system (CMS). While there are a ton of great free options that provide us with a CMS to power a website (WordPress, Drupal, etc.), it doesn’t hurt to peek under the hood and get a feel for how these systems work. To get our feet wet as back-end developers, we’ll be creating a simple PHP class that will: Create a databaseConnect to a databaseDisplay a form with two fieldsSave the form data in the databaseDisplay the saved data from the database Download Files This class is intended to give you a feel for how PHP and MySQL interact together, and to show the basics of a CMS. Building the Class Our first step is to simply lay out the class in a file named ‘simpleCMS.php’ so we have a road map to work with. As you can see, we’re creating one class with four variables and five methods. The Variables Build the Database Connect to the Database Build the Form <! <?

OBJECT ORIENTED PHP TUTORIAL FOR BEGINNERS Preamble The hardest thing to learn (and teach btw,) in object oriented PHP is the basics. But once you understand them, the rest will come much, much easier. But don’t be discouraged! You just found the easiest to understand tutorial out there on OOP and PHP. … Or so I’ve been told. About This Tutorial This tutorial is designed to teach total beginners object oriented PHP. This is not a long-winded theoretical blathering that you see all too often; instead, we actually start writing OO code very quickly. So before you begin, get out your favorite PHP code editor and be ready to write and run some object oriented PHP code. PS: scroll to the bottom of the page for the supporting videos. Thanks for reading, Stefan Mischook Introduction With the release of php5 in 2004, php programmers finally had the power to code with the ‘big boys’. In this tutorial, you will be guided (step-by-step) through the process of building and working with objects using php’s built-in OOP capabilities. OOP Videos

Easy PHP Blackhole Trap with WHOIS Lookup for Bad Bots One of my favorite security measures here at Perishable Press is the site’s virtual Blackhole trap for bad bots. The concept is simple: include a hidden link to a robots.txt-forbidden directory somewhere on your pages. Bots that ignore or disobey your robots rules will crawl the link and fall into the trap, which then performs a WHOIS Lookup and records the event in the blackhole data file. In five easy steps, you can set up your own Blackhole to trap bad bots and protect your site from evil scripts, bandwidth thieves, content scrapers, spammers, and other malicious behavior. The Blackhole is built with PHP, and uses a bit of .htaccess to protect the blackhole directory. These four files are all contained in a single directory named “blackhole”. Note: By default, .htaccess files are hidden on Windows and OS X, so to view them you need to enable “Show hidden files” on your machine, or use any FTP or code-editing software that is capable of displaying them (it’s a common feature).

Improve website load time by 500% with 3 lines of code | Aciddrop.com Major New Update - PHP SPEEDY: latest version available here There are 4 relatively easy ways by which you can speed up the time it takes a browser to download a page: Make fewer HTTP requestsAdd a far-future expires headerGzip your page's componentsMinify your JavaScript, CSS and HTML Following on from my post on joining CSS and JavaScript files, I have written a PHP script which will automatically do all of the above. The code require_once('class.compressor.php'); //Include the class. And the following at the bottom of the page: The Demo That's it! The class can be downloaded here: site speed boost class download Requirements A server running at least PHP4. Setting basic options Options can be set with a comma separated string as follows: $compressor = new compressor('css,javascript,page'); The string can contain 'css', 'javascript' and 'page' depending on which elements you would like to be compressed. Setting advanced options Note that "cachedir" should not include a trailing slash. Download

Good PHP Tutorials - Beginner To Advanced PHP Programming Tutorials Ten PHP Best Practices Tips that will get you a job | PHP vs .Net Posted by blake on Jun 4, 2008 in Code, Performance, PHP | 167 comments The last couple of weeks have been quite the experience for me. I was part of a big layoff at my former company, which was interesting. I've never been in that position before, and it's hard not to take it personally. I started watching the job boards, and a nice-looking full-time PHP position caught my eye, so I sent out a resume and landed an interview. Find the errors in the following code: So, give it a shot. If you got the missing comma in the parameter list, the "new Array()" error, the colon instead of a semi-colon, the '=' instead of '=>' in the foreach statement, and the erroneous use of '+' on the echo line, then congratulations, you found all the errors! That's not how I answered the question though. After pointing out the actual errors, I made a point of adding comments about those things I just mentioned. So, read on for my Ten PHP Best Practices Tips that will get you a job: 1. 2. 3. 4. 5. 6. 7. 8. 9.

Related: