Created
November 20, 2021 21:56
-
-
Save amrelarabi/ec14ca39829940f948afecbaeb434c09 to your computer and use it in GitHub Desktop.
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
<?php | |
// by value الحالة العادية | |
function addFive($num) { | |
$num += 5; | |
} | |
// by reference حالة تمرير المعاملات | |
function addSix(&$num) { | |
$num += 6; | |
} | |
$x = 10; | |
addFive( $x ); | |
// عند طباعة القيمة $x سنلاحظ انها 10 كما هى | |
echo $x; | |
addSix( $x ); | |
// فى هذه الحالة لأننا أستخدام تمرير المعاملات عن طريق المرجع سنلاحظ انه القيمة الأصلية للمتغير x تغيرت إلى القيمة الجديدة 16 | |
echo $x; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment