This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$var = "dangerous'"; // escape yapılmamış veri | |
$id = some_foo_number(); // int olması beklenen veri | |
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_title = %s WHERE ID = %d", $var, $id ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( $foo && ( $bar || $baz ) ) { ... | |
my_function( ( $x - 1 ) * 5, $y ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch ( $foo ) { | |
case 'bar': // doğru | |
case 'ba' : // yanlış | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$x = $foo['bar']; // doğru | |
$x = $foo[ 'bar' ]; // yanlış | |
$x = $foo[0]; // doğru | |
$x = $foo[ 0 ]; // yanlış | |
// Sadece değişken olunca boşluk bıraktık. | |
$x = $foo[ $bar ]; // doğru | |
$x = $foo[$bar]; // yanlış |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Doğru kullanım | |
(int) | |
(array) | |
(bool) | |
foreach ( (array) $foo as $bar ) { ... | |
$foo = (bool) $bar; | |
// Yanlış kullanım | |
(boolean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! $foo ) { ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ( $foo as $bar ) { ... | |
function my_function( $param1 = 'foo', $param2 = 'bar' ) { ... | |
function my_other_function() { ... | |
my_function( $param1, func_param( $param2 ) ); | |
my_other_function(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x === 23 | |
foo && bar | |
! foo | |
array( 1, 2, 3 ) | |
$baz . '-5' | |
$term .= 'X' |