Skip to content

Instantly share code, notes, and snippets.

switch( $type ) {
case 'foo':
some_function();
break;
case 'bar':
some_function();
break;
}
// Doğru kullanım
if( condition ) {
action1();
action2();
} elseif( condition2 && condition3 ) {
action3();
action4();
} else {
defaultaction();
}
<?php if ( have_posts() ) : ?>
<div class="hfeed">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID() ?>" class="<?php post_class() ?>">
<!-- ... -->
</article>
<?php endwhile; ?>
</div>
<?php endif; ?>
// Doğru kullanım
$args = array(
'echo' => false,
'include' => array( 1, 2 ),
);
// Yanlış kullanım
$args = [
'echo' => false,
'include' => [ 1, 2 ],
// Doğru kullanım
$foo = array(
'echo' => false,
'include' => 1,
);
$bar = esc_html__( 'Test Yazı', 'text-domain' );
test_fonksiyon( $foo, $bar );
// Yanlış kullanım
test_fonksiyon( array( echo => false, include => 1 ), esc_html__( 'Test Yazı', 'text-domain' ) );
// Açma kapama taglarına özel satır verdik.
function foo() {
?>
<div>
<?php
echo bar(
$baz,
$bat
);
?>
// Doğru kullanım
<?php ... ?>
<?php echo $var; ?>
// Yanlış kullanım
<? ... ?>
<?= $var ?>
x === 23
foo && bar
! foo
array( 1, 2, 3 )
$baz . '-5'
$term .= 'X'
foreach ( $foo as $bar ) { ...
function my_function( $param1 = 'foo', $param2 = 'bar' ) { ...
function my_other_function() { ...
my_function( $param1, func_param( $param2 ) );
my_other_function();
if ( ! $foo ) { ...