my sql

Security

The National Vulnerability Database stores all vulnerabilities found in computer software. The overall proportion of PHP-related vulnerabilities on the database amounted to: 20% in 2004, 28% in 2005, 43% in 2006, 36% in 2007, 35% in 2008, and 30% in 2009.[40] Most of these PHP-related vulnerabilities can be exploited remotely: they allow crackers to steal or destroy data from data sources linked to the webserver (such as an SQL database), send spam or contribute to DoS attacks using malware, which itself can be installed on the vulnerable servers.
These vulnerabilities are caused mostly by not following best practice programming rules: technical security flaws of the language itself or of its core libraries are not frequent (23 in 2008, about 1% of the total). [41][42]taint checking to detect automatically the lack of input validation which induces many issues. Such a feature is being developed for PHP,[43] but its inclusion in a release has been rejected several times in the past.[44][45] Recognizing that programmers cannot be trusted, some languages include
Hosting PHP applications on a server requires a careful and constant attention to deal with these security risks.[46] There are advanced protection patches such as Suhosin and Hardening-Patch, especially designed for web hosting environments.[47]

 Syntax


    
        PHP Test
    
    
        
             echo "Hello World";
             /* echo("Hello World"); works as well, although echo isn't a 
                function (it's a language construct). In some cases, such 
                as when multiple parameters are passed to echo, parameters 
                cannot be enclosed in parentheses */
        ?>
    

PHP code embedded within HTML
PHP only parses code within its delimiters. Anything outside its delimiters is sent directly to the output and is not processed by PHP (although non-PHP text is still subject to control structures described within PHP code). The most common delimiters are to open and ?> to close PHP sections. delimiters are also available, as are the shortened forms or (which is used to echo back a string or variable) and ?> as well as ASP-style short forms <% or <%= and %>. While short delimiters are used, they make script files less portable as their purpose can be disabled in the PHP configuration, and so they are discouraged.[48] The purpose of all these delimiters is to separate PHP code from non-PHP code, including HTML.[49]
The first form of delimiters, and ?>, in XHTML and other XML documents, creates correctly formed XML 'processing instructions'.[50] This means that the resulting mixture of PHP code and other markup in the server-side file is itself well-formed XML.
Variables are prefixed with a dollar symbol and a type does not need to be specified in advance. Unlike function and class names, variable names are case sensitive. Both double-quoted ("") and heredoc strings allow the ability to embed a variable's value into the string.[51] PHP treats newlines as whitespace in the manner of a free-form language (except when inside string quotes), and statements are terminated by a semicolon.[52] PHP has three types of comment syntax: /* */ marks block and inline comments; // as well as # are used for one-line comments.[53] The echo statement is one of several facilities PHP provides to output text (e.g. to a web browser).
In terms of keywords and language syntax, PHP is similar to most high level languages that follow the C style syntax. If conditions, for and while loops, and function returns are similar in syntax to languages such as C, C++, Java and Perl.

 Data types

PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signedintegers. Unsigned integers are converted to signed values in certain situations; this behavior is different from other programming languages.[54] Integer variables can be assigned using decimal (positive and negative), octal, and hexadecimal notations. Floating point numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.[55] PHP has a native BooleanJava and C++. Using the Boolean type conversion rules, non-zero values are interpreted as true and zero as false, as in Perl and C++.[55] The null data type represents a variable that has no value. The only value in the null data type is NULL.[55] Variables of the "resource" type represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension; examples include file, image, and database resources.[55] Arrays can contain elements of any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in hashes with both keys and values, and the two can be intermingled.[55] PHP also supports strings, which can be used with single quotes, double quotes, or heredoc syntax.[56] type that is similar to the native Boolean types in
The Standard PHP Library (SPL) attempts to solve standard problems and implements efficient data access interfaces and classes.[57]

 Functions

PHP has hundreds of base functions and thousands more via extensions. These functions are well documented on the PHP site; however, the built-in library has a wide variety of naming conventions and inconsistencies. PHP currently has no functions for thread programming, although it does support multiprocess programming on POSIX systems.[58]

 5.2 and earlier

Functions are not first-class functions and can only be referenced by their name, directly or dynamically by a variable containing the name of the function.[59] User-defined functions can be created at any time without being prototyped.[59] Functions can be defined inside code blocks, permitting a run-time decision as to whether or not a function should be defined. Function calls must use parentheses, with the exception of zero argument class constructor functions called with the PHP new operator, where parentheses are optional. PHP supports quasi-anonymous functions through the create_function() function, although they are not true anonymous functions because anonymous functions are nameless, but functions can only be referenced by name, or indirectly through a variable $function_name();, in PHP.[59]

 5.3 and newer

PHP gained support for closures. True anonymous functions are supported using the following syntax:
function getAdder($x)
{
    return function ($y) use ($x) {
        return $x + $y;
    };
}
 
$adder = getAdder(8);
echo $adder(2); // prints "10"
Here, getAdder() function creates a closure using parameter $x (keyword "use" forces getting variable from context), which takes additional argument $y and returns it to the caller. Such a function can be stored, given as the parameter to other functions, etc. For more details see Lambda functions and closures RFC.
The goto flow control device was made available in PHP 5.3 and is used as follows:
function lock()
{
    $file = fopen("file.txt","r+");
    retry:
    if(flock($file,LOCK_EX))
    {
        fwrite($file, "Success!");
        fclose($file);
        return 0;
    }
    else
        goto retry;
}
When lock() is called, PHP opens a file and tries to lock it. retry:, the target label, defines the point to which execution should return if flock() is unsuccessful and the goto retry; is called. goto is not unrestricted and requires that the target label be in the same file and context.

Objects

Basic object-oriented programming functionality was added in PHP 3 and improved in PHP 4.[2] Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance.[60] In previous versions of PHP, objects were handled like value types.[60] The drawback of this method was that the whole object was copied when a variable was assigned or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value. PHP 5 introduced private and protected member variables and methods, along with abstract classes and final classes as well as abstract methods and final methods. It also introduced a standard way of declaring constructors and destructors, similar to that of other object-oriented languages such as C++, and a standard exception handling model. Furthermore, PHP 5 added interfaces and allowed for multiple interfaces to be implemented. There are special interfaces that allow objects to interact with the runtime system. Objects implementing ArrayAccess can be used with array syntax and objects implementing Iterator or IteratorAggregate can be used with the foreach language construct. There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference at compile time.[61]
If the developer creates a copy of an object using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not. If not, it will call a default __clone() which will copy the object's properties. If a __clone() method is defined, then it will be responsible for setting the necessary properties in the created object. For convenience, the engine will supply a function that imports the properties of the source object, so that the programmer can start with a by-value replica of the source object and only override properties that need to be changed.[62]
Basic example of object-oriented programming as described above:
Class Person
{
 
    public $first;
    public $last;
 
    public function __construct($f,$l)
    {
 
        $this->first = $f;
        $this->last = $l;
 
    }
 
    public function greeting()
    {
 
        return 'Hello, my name is ' . $this->first . ' ' . $this->last . '.';
        // return 'Hello, my name is ' . $this->first . ' ' . $this->last . '.'; also works when not called from Person::greeting()
 
    }
 
}
 
$him = new Person('John','Smith');
$her = new Person('Sally','Davis');
 
echo $him->greeting(); // prints "Hello, my name is John Smith."
echo '
';
echo $her->greeting(); // prints "Hello, my name is Sally Davis."

wibiya widget