Created
March 25, 2023 23:40
-
-
Save yetimdasturchi/0b16eaf67a5054f061166824829034d8 to your computer and use it in GitHub Desktop.
Codesample for explain pre and post increments
This file contains hidden or 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
<?php | |
function pre( &$y ) { | |
$y = $y + 1; | |
return $y; | |
} | |
function post( &$y ) { | |
$old = $y; | |
$y = $y + 1; | |
return $old; | |
} | |
$x=1; printf( | |
"Pre:\n\tKirish: %d\n\tChiqish: %d\n", | |
pre( $x ), | |
$x | |
); | |
$x=1; printf( | |
"Post:\n\tKirish: %d\n\tChiqish: %d\n", | |
post( $x ), | |
$x | |
); | |
/* | |
Pre: | |
Kirish: 2 | |
Chiqish: 2 | |
Post: | |
Kirish: 1 | |
Chiqish: 2 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment