background preloader

10 Advanced PHP Tips Revisited - Smashing Magazine

10 Advanced PHP Tips Revisited - Smashing Magazine
Advertisement Here, on the Smashing Editorial team, we always try to meet the expectations of our readers. We do our best to avoid misunderstandings, and we try to spread knowedge and present only the best design practices and development techniques. However, sometimes we do make mistakes. And when we do, we apologize and do our best to correct what we’ve done. In November 2008 we published the article 10 Advanced PHP Tips To Improve Your Programming21. 10 Useful PHP Tips Revisited by Chris Shiflett and Sean Coates This article is a rebuttal to 10 Advanced PHP Tips To Improve Your Programming21 — henceforth referred to as the previous article — published last November here on Smashing Magazine. Listed below are 10 excellent techniques that PHP developers should learn and use every time they program. Unfortunately, the intrigue devolves into disappointment. 1. This particular tip is just a link to a useful resource with no discussion on how to use it. <? 2. 3. This brings us to our tip. 4. <?

10 tools for Modern PHP Development | DaveDevelopment Featured Posts Coding DCI in PHP I recently taken a closer look at DCI, this post describes my investigation as to how viable implementing DCI in PHP might be php dci bdd behat featured oop Silex Controllers as Services Using a custom controller resolver, we can create controllers as services much like how it's done with the full stack Symfony framework php featured silex dependency injection How I'm doing TDD with PHP I've been watching the Destroy All Software back catalog over the last couple of months and it's really inspired me to up my TDD game. php tdd bdd rambling behat phpunit featured Handling Symfony2 Events Asynchronously How many of your event listeners need to act synchronously? php symfony2 event driven architecture featured open source message queues silex Phpmig - Simple migrations for php Phpmig is a simple migrations system that was written to be easily adopted regardless of the framework or libraries you are using. php migrations pear featured open source Browse more blog posts

Nerd Paradise : 10 PHP Tips and Tricks Here are a few things worth mentioning that I've figured out during my years of writing PHP-based websites. Some of these might be obvious but are worth re-iterating. Others are things that I didn't consciously consider until learning the hard way sometimes multiple times. #10 - Never use MySQL commands directly Ever. $new_item_id = $db->insert("some query"); $update_success = $db->update("some query") > 0; #9 - Create an underlying API from the get go There comes a time in every PHP website's lifecycle where you want to go from a classical page-by-page layout to an AJAX or service-based presentation. #8 - Actually use functions PHP is a terrible language. #7 - Generate pages in two passes (data -> view) The following is too terribly common: $entries = $db->query("some select query to get a bunch of data"); for ($i = 0; $i < mysql_num_rows($entries); ++$i) { $entry = mysql_fetch_array($entries); echo blah blah blah $entry['foo'] blah blah $entry['meow'] blah $entry['whatever']; }

PHP: What You Need To Know To Play With The Web - Smashing Magaz Advertisement In this article, I’ll introduce you to the fundamentals of PHP. We’ll focus on using PHP to access Web services and on turning static HTML pages into dynamic ones by retrieving data from the Web and by showing different content depending on what the user has entered in a form or requested in the URL. You won’t come out a professional PHP developer, but you’ll be well on your way to building a small page that uses Web services. What Is PHP? PHP is a server-side language that has become a massive success for three reasons: It is a very easy and forgiving language. Installing PHP Locally, And Your First Code To run PHP locally on your computer, you’ll need a local server with PHP enabled. In this file, type (or copy and paste) the following: <? If you open this file in a browser by accessing your XAMPP or MAMP installation (via or you should see the following: But you won’t see that. <? PHP blocks start with <? <? <ul><? <? <?

PHP Tips and Tricks Introduction In previous articles we've touched on some major sections such as MySQLi, Classes and cURL. There are a lot of other tips and tricks that you should look at, and a few of them are covered below, a couple of which are transferrable between languages. Ternary Operators A ternary operator is a different way to layout a simple if statement. $name = (! This might look complex to begin with but there are three sections to a ternary operator: The conditional ! The ternary operator will return either the true or false conditional, and therefore it will be assigned to $name. if(! The two above and the ternary operator will all end up with $name having something assigned to it. Nesting While not advisable, it is possible to nest ternary operators within each other much like you would with standard if statements, or to form a long string of if...else if...else if...else statements. Class Autoloading The Code Which will work exactly the same as the method of implementation above. Referencing

PHP Tips and Tricks - KillerPHP.com Blog Hi, I wasn’t sure what category to put this blog post in, because it isn’t really about PHP code or even about code in general, but there are a few things to learn from my recent update to the Killervideostore.com website: If adding something to a page/site DOES NOT have any measurable impact, remove it.Remember that people tend to skim pages, so keep that in mind when structuring your UI.Seemingly small things can have a big impact on user behaviour and sales. Remove the unnecessary: I am always experimenting with different variations to the layouts of our pages – adding/removing buttons, adding a video, replacing link text to image buttons etc … The thing you should always strive for is simplicity – remove what is not needed. We recently added a video in our header, introducing the video store to anyone who cared to clicked on the video … very few did. Check out the old killervideostore header- with video in place: .. Now compare it to the new killervideostore header. People Skim Pages:

Top 10 CSS Table Designs Advertisement Many companies try to create a great experience for customers. But few are willing to make the changes required to deliver on that promise. Tables have got to be one of the most difficult objects to style in the Web, thanks to the cryptic markup, the amount of detail we have to take care of, and lack of browser compatibility. Further Reading on SmashingMag: Link Designing Designing Print With CSS1The New Standard for The Web: CSS Grid and Flexbox2Taking Pattern Libraries3 To The Next Level First things first Link We start with a valid xhtml 1.0 strict markup. <table id="..." You can read more about xhtml table markup in HTML Dog’s Table Section4. Before we start, let’s review the general rule of thumb for styling of tables: Tables love space. Now that we are all set up let’s get going, shall we? Today, too many websites are still inaccessible. 1. Horizontal tables are tables that are read rather horizontally than vertically. Important! 2. Important! 3. Important! 4. ... Important!

How to Create a Search Feature with PHP and MySQL Digg This Add to del.icio.us Developing a robust, interactive and engaging Web site involves many different avenues, such as interactive pop-out menu’s using dynamic JavaScript, Cascading Style Sheets (CSS), complex maps that allows visitors to rollover individual sections for detailed information, forms designed and formatted with CSS and are programmed to collect and send visitor feedback to a specified recipient. Other features could include: database driven pages that display a current member directory, a customized blog section that enables administrators to manage postings and allow random users in coordination with CAPTCHA techniques to post remarks to an article. Arguably, one of the most popular features of any database driven site is a searchable form feature that allows anyone to search for current staff members of an organization and find additional information, such as their email address or phone number. Before we begin, you'll need to download the project files. <!

PHP 5 Tutorial

Related: