Posts

Showing posts with the label PHP

​ WordPress performance: 17 things to do right now

Image
​ WordPress has a low barrier to entry and encourages experimentation, which are both good things for developers. But once a WordPress site is up and running, you need to get it running fast enough to keep Google happy. Luckily WordPress performance is easy to get started with: there are quite a few quick things you can do to improve the performance of vanilla WordPress installs. Check your loops first for expensive code . Optimization-wise, loops are low-hanging fruit. Use GLPTimer , cache grind, or similar to find bottlenecks. Focus on the WordPress loop and any other big loops. Minimise SQL calls inside loops: see #2. For other stuff commonly seen inside loops see #7 and #15. Start caching lookup data . Pre-fetch all the results you need in a single query, and store them in a single array. Optimize the query so it only selects the columns you actually need. For example: say for each post you also want to look up some taxonomy term names a...

​ PHP Web Programming and Business Benefits of PHP Development

Image
​ PHP is a popular scripting language that evolved from what was called the Personal Home Page by Rasmus Lerdorf. Initially developed as a series of scripts that was used to track visitors to a webpage, it has turned out to be an interpreter on most operating systems and platforms and is considered the most popular language in the field of web development today. PHP can be used to create a range of web applications including personal websites, e-commerce applications as well as community web portals. As per statistics, about 35% of web traffic is handled by it while a vast majority of websites including those of Facebook and Wikipedia have used this language. Even the best blogging platforms like WordPress or Joomla are built using the platform. It is not without reason that this language has become so widely preferred as well as used. Several factors have contributed to its success. Here is a brief overview of how businesses benefit from PHP web developme...

Change Virtue mart Product Category page thumbnail not pop up that goes to product details

Image

10 improvements in PHP 5.5.0 for web developers

Takeaway: Here are examples of some new features and improvements in the latest release of PHP. PHP 5.5.0 has been released, bringing with it a host of new features and fixes. TechRepublic has rounded up 10 improvements that web developers should look out for in the new release. One key difference to note before upgrading is that support for Windows XP and 2003 has been dropped as of 5.5.0. Other backwardly incompatible changes introduced by the release can be found here . #1 Generators are now available Generators provide a simple way to iterate through data without having to write a class implementing the Iterator interface. Just like any other function a generator is defined with the function keyword, but unlike a normal function that just returns a result once, a generator can send back as many results as needed using the yield keyword . A simple example of using a generator function to print out a positive sequence of integers is shown below. function xrange($st...

How to Remove HTML Tags from WordPress 3.x Comment Box

This tutorial is going to guide you how to get rid of the html code under the message box in the WordPress twenty ten’s comment template. First a warning, do not edit or delete the code from WordPress 3.x core files, instead hide it with CSS code. Using CSS has the advantage of not requiring core file modifications (always a bad idea). Put simply, you need to add the following line of code to the your Theme style sheet. .form-allowed-tags { display:none; } So, using the   WP Twenty ten   theme as an example, here are the steps: 1. Login to your WordPress dashboard 2. Go to Appearance/Editor. 3. Open the stylesheet file, style.css. It will be listed at the bottom of the right-hand column. 4. Go to the end of the style.css style sheet and enter the code on a new line: .form-allowed-tags { display:none; } 5. Save the file (Update File button) and you’re done. 6. And that’s all there is too it. If you now inspect your comment box the offending HTML Tags will have gone.

Understanding OOP Polymorphism in PHP with example

Polymorphism in PHP Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface. The simple meaning of Polymorphism is ‘many forms’. Polymorphism allows us to use functions with same name but with different functionality. Here is an example code: class Animal { public $hungry = 'hell yeah.' ; function eat ( $food ) { $this -> hungry = 'not so much.' ; } } class Bird extends Animal { function eat ( $food ) { if ( $food == 'seed' ) { $this -> hungry = 'not so much.' ; } else { echo 'barf, I only like seed!' ; } } } As you can see, Bird isn’t all that different from Dog. They both eat food. However, because they are not the same type of Animal, they behave differently in response to the $food they are being fed. This is referred to as having their own implementations of the interface provided by Animal, or simpl...

Ten PHP Best Practices Tips that will get you a job

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. Before the face-to-face portion, I chatted with the owner and head programmer on a conference call, and they ended up sending me a technical assessment quiz. One particular question caught my eye on this quiz… it looked something like this: Find the errors in the following code: <? function baz($y $z) { $x = new Array(); $x[sales] = 60; $x[profit] = 20: foreach($x as $key = $value) { echo $key+" "+$value+"<BR>"; } } ?> So, give it a shot. How many can you find? If you got the missing comma in the parameter list, the "new Array()" error, th...

42 Ways to Optimize your PHP Code

If a method can be static, declare it static. Speed improvement is by a factor of 4. echo is faster than print . Use echo's multiple parameters instead of string concatenation. Set the maxvalue for your for-loops before and not in the loop. Unset your variables to free memory, especially large arrays. Avoid magic like __get, __set, __autoload require_once() is expensive Use full paths in includes and requires, less time spent on resolving the OS paths. If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time() See if you can use strncasecmp, strpbrk and stripos instead of regex str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4 If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, i...

Select all rows in a table But except one in in that table?

You have a few options: SELECT * FROM table WHERE id != 4; SELECT * FROM table WHERE NOT id = 4; SELECT * FROM table WHERE id <> 4; Also, considering perhaps sometime in the future you may want to add/remove id's to this list, perhaps another table listing id's which you don't want selectable would be a good idea. In which case you would have: SELECT * FROM table WHERE id NOT IN (SELECT id FROM exempt_items_table); Source:-  http://stackoverflow.com/users/263467/tim

How to remove tag amchart copyright from Chart

Hi find the below text in amcharts.js   file. "#000000","Verdana", 11 ,"start" Change the parameter 11 to 0 Enjoy with amChart ...

PHP Constructor

PHP Constructor is use to preset the value of variable , sessions and cookies.When a PHP class is called 1st time automatically class will run class constructor function.In other word we can say that constructor function is use to initialize the object of the class and default constructor will execute automatically when the object of the class is called 1st time. Rules for constructor : Constructor does not have return type It has same name as the name of the class It cannot be inherit It used to allocate resources such as memory, to dynamic data member of a class Types of constructor : 1. Default constructor :- Default constructor is those constructor which has no parameter . it will execute by default when class is executed. There is only one default constructor in a class 2. Parametrized Constructor : those constructor which has different -2 parameter with different-2 data types is called parametrized constructor .one class can contain more than one parametrized constructor ...