1 / 7

Tips for improving PHP code by Study Section

Improve Code for Better Process. Code improvement is another important thing for performance optimization.

Download Presentation

Tips for improving PHP code by Study Section

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tips for improvingPHP code

  2. Problem 1: Not using PHP built-in function • Sometimes we try to solve the small problem with our own function instead of a built-in PHP function that provides the functionality. • Solution:PHP provides many useful functions that remove the need to “refresh the wheel”, and will often complete the work much better than anything typed by a standard program. Therefore, if you are experiencing the need to write complex tasks that you think may already exist, it is best to search the Internet (and PHP scripts in particular) before you start writing your code.

  3. Problem 2: Not creating functions • Not creating functions is a typical problem for developers mainly for beginners. The problem stems from the fact that a programmer can write multiple lines of PHP scripts without having to encrypt parts of the code into tasks. This is problematic because it is difficult to understand what the code actually does without going deeper into it, and the developer may repeat himself unintentionally. • Solution: • Dividing the functions into small individual functions is a good solution to this problem.

  4. Problem 3: Code Duplication • If you are writing the same code more than one or two times then there will be something wrong with the code. In this way you are violating the important rule of modern code writing: Do not Repeat Yourself (DRY). This is important because if the code is finished and one code is written more than one time and after that, if there need to make changes, then you have to make more efforts to make changes in all the places. • Solution: • Wrap the code in a function is a good way to avoid duplication. Then the function can be called whenever needed.

  5. Problem 4: Vague names for functions and variables • Another problem that seems to exist even within the experienced system is that of the fixed and unambiguous words that do not change variables and function. For example, a job name like "doSomething" is not very clear. The problem may be due to a number of reasons: a lack of awareness, laziness, or the result of an activity that was written to perform a particular action, but which ended up taking another action instead. It creates the problem of readability of the code and makes it difficult in maintaining and making changes in the code. • Solution:The solution is to assign an illustrative word that contains 2 to 3 words or more to function and variable names. • For More Tips Visit Study Section

  6. Free Online Php Certification Exam • StudySection offers PHP Programming Online Certifications at • Foundation • Advanced • Expert • levels apart from many other free online certification exams.

  7. About Study Section • Welcome to StudySection - the most loved online platform for eCertification in several subjects including but not limited to Software Development, Quality Assurance, Business Administration, Project Management, English, Aptitude and more. From more than 70 countries students are StudySection Certified. If you are not yet StudySection certified it's not late. You can start right now. • Being StudySection Certified helps you take your education level few notches up and have an edge over other candidates when you need it the most. Globally, our students are employed in different organizations and are utilizing the benefit of being certified with us.

More Related