Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Frederick Vanbrabant:
What Performance Tricks Actually Work
Jul 25, 2018 @ 14:55:24

Frederick Vanbrabant has a new post to his site sharing some performance tips you can integrate into your PHP code to help improve its overall processing time. He also talks some about a few that are just myths and debunks them.

We’ve all been there before, you submit a pull request and moments later you get a comment like: “Hey you should use a native function here, they are so much faster” or “You can declare this final, that way we save some processing power”.

It’s great that we as developers keep an eye on this, but how true are these thing. And are they still a thing in newer PHP versions?

He goes through a list of ten tricks that have been widely shared and creates some simple benchmarks around their use:

  • single versus double quotes
  • JSON handling versus XML handling
  • speed difference from using layered objects
  • native array functions versus loops
  • fetching an array item by quoted ID versus just ID
  • performance difference of throwing exceptions
  • impact of unused variables
  • magic methods versus normal methods
  • final versus non-final classes
  • comments in code

For each of the items in the list he includes the example code he used for the benchmark and the output from the PHPBench tool.

tagged: performance trick development tutorial

Link: https://frederickvanbrabant.com/2018/07/24/php-performance.html

NetTuts.com:
Advanced CodeIgniter Techniques and Tricks
Jun 07, 2012 @ 18:04:01

On the NetTuts.com blog today there's a new handy post for the CodeIgniter users out there - some more advanced tips and tricks that you can use in your CI-based apps.

CodeIgniter is a widely used PHP framework that aims to help developers write better structured code and remove boilerplate tasks from the workflow. In this article, I’m going to explain some incredibly useful techniques to use when developing applications using CodeIgniter.

They cover things like setting up easier configuration parameters, optional config settings, creating HTML emails, application versions and separate response formats.

tagged: codeigniter technique trick advanced tutorial

Link:

Andrew Eddie's Blog:
Making the most out of Code Assist in Eclipse/PDT and Zend Studio for PHP
Dec 01, 2011 @ 18:55:32

Andrew Eddie has posted a helpful tutorial for Eclipse users out there showing how to get the most our of code assist in Eclipse PDT/Zend Studio.

One of the powerful features of an IDE like Eclipse is the ability for it to "read" your code and give you some assistance about your API as you type. This could include things like class property or methods names, constants, functions, argument lists, and so on. Eclipse/PDT and ZendStudio do this by parsing a PHP class directly, but they also look at your docblocks and some other special comments where the raw PHP is not enough. This article is a bag of tricks that help you get the most out of code assistance using Eclipse/PDT or Zend Studio in those awkward corners of your code that you might have through previously inaccessible.

Among his tips are things like adding "@var" declarations to help with code completion, type hinting on methods/functions, using the "@property" annotation and using a "this" trick to override what class the IDE sees as the local object. ,/p>

tagged: eclipse zendstudio ide hint trick docblock annotation codeassist

Link:

PHPBuilder.com:
Top 10 phpMyAdmin Tips and Tricks You May Not Know
Feb 09, 2011 @ 18:41:54

In this new article on PHPBuilder.com today, they share ten handy tips that you might not have known you could do with the phpMyAdmin tool.

Despite approaching its 12th birthday, phpMyAdmin is still under active development, with at least one significant version released every year since the project's inception. In fact even after almost a decade of use I still marvel over discovering features which I had no idea existed. In this article I thought I'd highlight 10 useful phpMyAdmin features which may have escaped you during your daily interaction with this fantastic utility.

Making the list of their ten tips are things like:

  • Manage User Privileges
  • Change the Theme
  • Monitor Server Status
  • Create PDF Relational Diagrams
  • Use Your Native Language
tagged: phpmyadmin tip trick tutorial

Link:

PHPBuilder.com:
Six Cool PHP Tricks You May Not Know
Apr 23, 2010 @ 13:44:24

On PHPBuilder.com there's a new article with a few things - six things, to be exact - that you might not know about the PHP language as written up by Chris Roane.

Over the years I've come across some useful tricks in PHP that are not obvious, but are worth mentioning. This is not meant to be a comprehensive list of all the useful tricks that you can do with PHP.

The list of six includes:

  • Count Characters in a String
  • Use Single Quotes When Possible
  • Use Arrays in Form Fields
  • PHP Output Buffering
tagged: trick quote array output buffering

Link:

Juozas Kaziukenas' Blog:
Zend Framework tips and tricks
Feb 01, 2010 @ 15:46:30

Juozas Kaziukenas has a new post to his blog with some tips and tricks for working with the Zend Framework including working with globals, using the framework part of the framework and getting form values a bit more correctly.

Most of the outlined problems and solutions are focused on testability, maintainability and other good code practices. If you are not familiar with them, I recommend read about them ASAP as there is big chance that you are doing those things described in this post and don't even realize how wrong they are. Believe me, you will soon find yourself a way better developer.

He also advocates splitting out logic and putting it into a model to make future enhancements easier (and make for cleaner code), avoiding the use of exit/die in your scripts and quick mentions of the includePaths setting in the application.ini file as well as things like addJavascriptFile/addStylesheet/addOnload.

tagged: zendframework tip trick

Link:

SitePoint PHP Blog:
A Note on Google's So-called Best Practices
Jun 26, 2009 @ 20:54:43

On the SitePoint PHP blog today Troels Knak-Nielsen has posted some of his own thoughts about the performance tips that Google recently published for PHP.

The project includes an article on "PHP performance tips", which is bordering on being ridiculous. There are of course lots of blog posts with similar nonsense around the web, but since this is being endorsed by Google, it’s fair to assume that people might take it at face value. That’s unfortunate, as almost none of it is true. The PHP Team responded back with this message, wherein they refute the unfounded nonsense.

He notes that these practices aren't the best road to optimization and, depending on when they might be used, could be harmful to the development of the application. He also recommends XDebug if you really want to get to know where your application is struggling.

tagged: trick bad optimize bestpractices

Link:

Cal Evan's Blog:
Three Lists I Never Want to See Again
Apr 23, 2009 @ 13:43:56

You're all thinking it - Cal Evans finally just put it into words with his list of "lists [he] never wants to see again" in the PHP world.

Lists are all the rave these days for bloggers. The reason is obvious, they require very little thought or research to create. So, in keeping with the current trend, here is my list of three lists never want to see again.

His list of three are posts that contain:

  • 5,000 PHP classes and tutorials
  • 50 new PHP tricks you didn’t know, didn’t want to know, and will get you fired if you ever use them on the job
  • Top PHP Frameworks

Blog posts should be about real content, not just spitting back out something anyone could put together in ten minutes with a little copy and paste. As Cal puts it:

If you are using a new PHP class, CMS, framework, or have a new technique you want to share, share it. Write a blog post and tell me how or why it solved your problem; bonus points if you describe the problem that it solved. You are not adding to the conversation is you are just recapping what others have said.
tagged: unoriginal framework trick tutorial class blog list

Link:

Smashing Magazine:
10 Useful RSS-Tricks and Hacks For WordPress
Dec 03, 2008 @ 16:28:41

Smashing Magazine has a few helpful RSS tips and tricks for WordPress users out there:

Let's take a look at 10 useful, yet rather unknown RSS-tricks for WordPress. Each section of the article presents a problem, suggests a solution and provides you with an explanation of the solution, so that you can not just solve some of your RSS-related problems but also understand what you are actually doing.

Here's their list:

  • Control When Your Posts are Available via RSS
  • Redirecting WordPress Feeds to FeedBurner Feeds
  • Insert Ads (or Anything Else) in Your RSS Feed
  • Format Your Images for Feed Readers
  • Provide Your Readers with a Feed for Each Post
  • Exclude Categories from Your RSS Feed
  • Display Any RSS Feed on Your WordPress Blog
  • Use Category-Specific RSS Feeds
  • List RSS Feeds by Category
  • Get Rid of RSS Feeds the Clean Way
tagged: wordpress rss feed tip trick feedburner image category ad

Link:

David Otton's Blog:
Neat PHP Tricks: How To Assign References to Globals
Nov 10, 2008 @ 15:32:18

David Otton has a new neat PHP trick posted today - assigning references to global values.

What follows isn't so much a PHP trick as a fix for something that really should work, but doesn't. Although the manual implies that the behaviour described below is specific to Zend Engine 1, all my tests were performed against Zend Engine 2.2, PHP 5.2.5.

His example compares making a new stdClass both with and without a reference on the it and var_dumps out the result. The method with the reference fails silently, however and isn't able to correctly assign it to the global. He recommends a work-around though - setting it directly to the $GLOBALS superglobal.

tagged: reference global superglobal trick assign object example

Link:


Trending Topics: