Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "PHP"

From NetSec
Jump to: navigation, search
Line 14: Line 14:
 
=Boolean Logic=
 
=Boolean Logic=
 
=Loops=
 
=Loops=
 +
==Ternary Conditionals==
 
=User Input=
 
=User Input=
 
=User-Defined Functions=
 
=User-Defined Functions=
 +
 +
Defining functions in [[PHP]] is accomplished using the ``function'' keyword, followed by the function name and comma delimited arguments, surrounded by parenthesis:
 +
 +
{{code
 +
|text=
 +
<source lang="php">
 +
function myFunction(arg1, arg2) {
 +
...
 +
}
 +
</source>
 +
}}
 +
 +
If the function is encapsulated in an object, you may specify the visibility of the function, public, protected or private.
 +
 +
{{code
 +
|text=
 +
<source lang="php">
 +
class MyClass
 +
{
 +
    public function myFunction(arg1, arg2) {
 +
    ...
 +
    }
 +
...
 +
</source>
 +
}}
 +
 +
Unlike languages, such as [[Perl]] or [[Python]], [[PHP]] member functions implicitly extract their parent into the $this variable.
 +
 
=Security=
 
=Security=
 
* Type Handling
 
* Type Handling
 
* XSS
 
* XSS
 
* SQL Injection
 
* SQL Injection

Revision as of 01:12, 16 May 2012

PHP is one of many interpreted languages written in C.

Development Environment

php cli

  • php -l check syntax
  • php -v version
  • php -e oneliner
Xochipilli says
Many Linux distributions package the PHP CLI separately

Pear/Pecl

Your first application

Variables and data types

Boolean Logic

Loops

Ternary Conditionals

User Input

User-Defined Functions

Defining functions in PHP is accomplished using the ``function keyword, followed by the function name and comma delimited arguments, surrounded by parenthesis:

 
function myFunction(arg1, arg2) {
...
}
 

If the function is encapsulated in an object, you may specify the visibility of the function, public, protected or private.

 
class MyClass
{
    public function myFunction(arg1, arg2) {
    ...
    }
...
 

Unlike languages, such as Perl or Python, PHP member functions implicitly extract their parent into the $this variable.

Security

  • Type Handling
  • XSS
  • SQL Injection