Top 10 PHP Tips for Developers

I have always wanted to write an article like this, because I think about it all the time – what 10 things would I deem the most important to pass on to someone else? Well, after literally years of thought I think I have come up with the best list that I can think of. So, without further ado, let’s get to it.

1) Go OOP

If you have not yet entered the realm of Object Oriented Programming like PHP development, then you are at a disadvantage, and you are falling behind fast.

OOP is essentially a method of programming with the use of classes, or Objects, which tie like things together, remove the need for repetition of code and perform the basic tasks of production very simply. Objects are essentially classes that collect a bunch of functions together and wrap them in a wrapper that can be reused over and over again without the need to rewrite functionality or procedures every time you need to do something.

Procedural Programming works by following a routine from the top to the bottom of each page as the server reads every file on your server. With OOP, there could be one or two objects being instantiated, which, in turn could instantiate a few, a hundred or a thousand other objects which could all perform certain tasks depending on variables passed into the objects. OOP is faster, simpler, easier to debug, uses less server resources, less code, is faster loading and more logical to work with once you figure out the basic principles. Go OOP – It changed my development style forever.

2) Stay Away from Anything Ending With _once()

We all know that include() simply gives us a warning if it fails, while require() kills the script with a fatal error when it fails. What we don’t forget is that include_once() and require_once() is extremely hard on server resources. There is nothing we can do about it; it’s how PHP is set up. Just remember that these things kill your server resources, especially on a huge framework, and if you plan your code properly you won’t even need it anyway.

3) Develop With Error Reporting On

The very first thing you do when starting a new project is to turn error reporting to E_ALL, and you should only turn it off ten seconds before going to production mode. I do this with every project that I build and there is nothing better than running a project in full production mode and not even getting one error. Besides that, with error reporting on, you pick up any small errors that will eventually grow up to bite you in the… well, you get my point.

PHP Development

4) Use A Framework If You Need One

Ok, so Rasmus Lerdorf says you shouldn’t use a framework because he could quite conclusively prove that a framework is much slower than normal PHP code when it came to printing a simple “Hello World” application. Two things to mention here though: you are not Rasmus Lerdorf and I bet you won’t be building a “Hello World” application every time you web development something. Frameworks that help you do the tedious things can help, although you will have to learn how the frameworks function first in order to make things simple, but that’s the only real trade-off. Plus you stand less chance of writing bad code when someone else has written most of it for you, but let’s pretend I didn’t say that.

5) Use PHP’s Inbuilt Functions

Ok, you want to count the amount of keys in an array? You can loop through the array and simply increment a value for each iteration, right? Or you can just use the built in PHP function count(), which does just what it should. PHP has many built-in functions that can do what you need them to, so check out the manual to make sure you are doing it in the best way possible.

6) Protect Your Database

The best and safest way is to use mysql_real_escape_string() for all database before it is added to the database. This function makes all strings safe in terms of quotes and other functions that can harm your database or contain malicious code, so use it to be sure you have taken the first step against protection of your data. Another thing you can do is validate all POST and GET strings, never use $_REQUEST, and make sure all form submitted data is of the right type and value before adding it to a database query.

7) Use POST Not GET

Ok, this isn’t always possible, but when it’s really not necessary, don’t use GET, use POST. The reason is simple – GET is simple to emulate, all I need to do is add something to my address bar and I can hack your project. Obviously GET is the easy way to do pagination and permalinks, but when using form submission especially, stay with POST, it’s safer.

8) Draw Before You Code

A good practice to get into is to wireframe your projects, even if you are just scribbling a few notes on a piece of paper. It is very important to actually give the mechanics of you application some thought before sitting down to start coding, because in the process of planning it you will actually iron out the difficulties in your head and avoid the major headache that comes with the face palm when you realize that everything you just did is either wrong, not needed, or just silly.

9) Understand Your Project

An artist cannot draw something that he has not seen before. A singer cannot sing a song that he has not heard before. You cannot code a project that you do not fully understand. If you do not understand exactly what it needs to do, and how it needs to it, you cannot build it.

10) Code Code Code

If I could get one thing through to anyone reading this, this is it. You cannot become a good developer by reading. You cannot become a good developer by watching someone develop. The one and only tried and trusted method, is to actually write code. But – and here is the trick – build real things! Do not go and code something that you have no interest in, or will never use. Build what you like, and you will be excited and interested by it, and you will learn. Then, make it awesome, build upon it, and make it better.

Article Source: http://www.htmlgoodies.com/beyond/php/article.php/3907521

 

Advertisements

How You Differentiate Web Design and Web Development

The difference between web design and web development has become unclear. This confusion creates problems for a web design company and its clients. Web design has become a common term that encompasses design and development.

It is important for companies to make their clients aware that a successful website requires excellent design and development. Equally, clients should be prepared to make the effort to understand the difference. This understanding makes the specification and approval process more straightforward.

Web Design versus Web Development

Web design determines the look and feel of a website. It covers the layout, navigation and colors of a website. It may also include graphic and logo design. Web design is more concerned with aesthetics and user experience than functions.  A web designer will make a website easy to use and fit for purpose.

In contrast, web development provides the functions and features of a website. It is about the back end programming and not the face of a website. Functions covered by web development include registration, content management systems, e-commerce and any database applications. Web development enables visitors to carry out actions on a website.

Web Design and Web Development Skills

A good web designer will have graphic design skills and a good understanding of marketing. He or she will know how to grab the attention of visitors and encourage them to explore a website.

A good web developer will have excellent programming skills and be able to use a range of programming tools. He or she will be able to provide solutions to give a website the functions required.

There will be some overlap of skills between web designers and web developers. It is unusual for one person to be both an excellent designer and developer.

Web Design and Web Development Tools

Web designers use software such as Photoshop, Flash and Fireworks. They will also have a good working knowledge of typography, color theory and web accessibility.

Web developers will use a range of programming tools such as ASP, Javascript, XML and SQL. These are just some of the more well-known tools. There are many others and new tools are being developed all the time. For example, mobile apps have created a huge demand for developers with the relevant knowledge.

Web Design, Web Development and WordPress

The development of WordPress provides an interesting example of the difference between web design and web development. The web design of a WordPress site is determined by selecting a theme. The theme includes the use of colors, columns, fonts, navigation and titles.

After selecting a WordPress theme, you may add functionality to your website by using widgets and selecting plug-ins. These functions equate to web development.

Many people with no web design and development skills have created reasonable websites. However, experienced web designers and developers can create great websites. Such websites will have unique designs, functions and features.

Which is more important?

Research has shown that visitors judge a website in just a few seconds. Therefore, good website design is required to make the website attractive and easy to use. Good website development is required to give the website interesting features and functions. Ideally, web designers and web developers should work together to retain visitors and encourage return visits. Design and development are equally important.

In conclusion, both web design and web development is essential to produce an effective website. Web design should be integrated with web development. This approach gives the best chance of creating an outstanding website.

PHP Development and Its profits

PHP is the open source object-oriented programming language. Its user-friendly interface provides quality output easily. Due to its pre-built function, it has been widely used to develop dynamic and creative applications easily. It can easily be integrated with HTML, so most web developers are using PHP for any application. It has some built-in features that help in creating complex applications within a minute. When developing a website or application you should think again to develop this using PHP development. PHP language is appropriate for you to build your application and website.

php_img

Although it is an open source everyone on the network can access and customize your code but your safety is very high. All website owners or webmasters are always thinking about your application and website. PHP has security easier. Its object-oriented feature helps PHP developers to build applications seamless and free of errors. It has more advantages for the world of modern web application built according to the needs. According to the market demand for software applications developers are building nice PHP applications within a couple of times as per the requirement of the project.
Here are some of the benefits of PHP application development.

  • It’s open to work and edit code. You do not pay any money to set up the environment as the components are free.
  • You can use this to build simple to complex websites. E-commerce, shopping, financial, banking and other applications can be easily created by PHP.
  • This language is very familiar and easily integrates with others. PHP developer can easily mix with html codes. It has any link with C ++. It can be easily understood.
  • It has an independent platform, so it can run on all major operating systems such as Linux, UNIX, Mac OS and Windows.
  • PHP Framework can easily supported with great network service provided as Apache, Microsoft IIS, Netscape, personal web server, iPlanet etc.
  • Faster and development of the square can be easily done through PHP. Time decreases server load significantly ecommerce, CRM and CMS applications can easily do.
  • It is a highly reliable platform development for 15 years by thousands of developers. It has the ability and versatility to develop web applications and major websites.
  • It is very cost effective compared to other programming language.

Web development has increased risk and involves PHP has decreased risks in the development and security of both sides. We have PHP application developers with extensive experience to meet and provide service as needed. We also get some highly significant evaluations of our customers outside source.