Wednesday, 14 January 2015

PHP

Definition
The PHP Hypertext Preprocessor (PHP — yes, the first “P” in the acronym does indeed stand for PHP!) allows web developers to create dynamic content that interacts with databases. PHP applications are normally found on Linux servers and in conjunction with MySQL databases. It provides those servers with functionality similar to that provided to the Windows platform by Active Server Pages technology.
Advantages Of PHP
  • PHP is flexible. Use OOP or not. Use naming convention(s) or not
  • Programmers of Java, PERL, BASIC, and other popular languages can find many parallels to ease transition to PHP
  • It can be optimized, even “compiled” for performance closer to that of more established compiled languages
  • PHP is accessible. It’s available for free.
  • A basic PHP script can be created without a firm understanding of programming principals, compilation, and other currently important programming concepts.
Disadvantages Of PHP
  • PHP is loosely typed. For developers of all skill levels, this allows room for unexpected behavior due to programmer error that many other languages might not permit. [Of course, few if any languages can protect from developer error!]
  • Out of the box, PHP tends to execute more slowly than assembly, C, and other compiled languages.
  • There are many ways to do one thing, and many cases where a function has ambiguous handling due to legacy support or PHP development history.
  • Web programming (regardless of language) is open to security flaws
    due to unimplemented or unknown vulnerabilities, takes a bit more
    caution.
  • If you want to do more than just HTML/CSS pages on the client you
    need to also add javascript, java or other client-side language in
    your output (goes for Perl and some other languages).
PHP – Function
A function is just a name we give to a block of code that can be executed whenever we need it. This might not seem like that big of an idea, but believe me, when you understand and use functions you will be able to save a ton of time and write code that is much more readable!
<?php functionaccompany(){ } ?>
With a properly formatted function in place, we can now fill in the code that we want our function to execute. Do you see the curly braces in the above example “{ }”? These braces define where our function’s code goes. The opening curly brace “{” tells php that the function’s code is starting and a closing curly brace “}” tells PHP that our function is done!
We want our function to print out the company motto each time it’s called, so that sounds like it’s a job for the echo command! For Example

No comments:

Post a Comment