Value passed :   Any change to the value within the scope of the function It is ignored outside the function ;

reference :  Any change to the value within the scope of the function These changes can also be reflected outside the function ;

Advantages and disadvantages : When passing by value ,php The value must be copied . Especially for large strings and objects , It will be a costly operation .
Passing by reference does not need to copy values , Good for performance improvement .

<?php
$name = "aa";
function add_img(&$name)
{
$name = "bb"; }
add_img($name);
echo $name; // Output bb, No aa

php The difference between intermediate value and reference . When to transmit value and when to transmit reference ? More articles about

  1. java Medium this And super The difference between

    java Medium this And super The difference between 1. Subclass constructor if you want to reference super Words , Must take super At the top of the function The code is as follows : class Base { Base() { System.out.pr ...

  2. php The difference between value passing and reference passing

    php The difference between value passing and reference passing is called value passing , That is, only the value of the object is passed to the target object , Equivalent to copy: The system will re open up an identical memory space for the target object . The so-called pass on quotation , In other words, the address of the object in memory is passed to the target object , It's equivalent to making ...

  3. 5 individual php example , Explain the difference between value passing and reference passing in detail

    Pass value : Is to assign the value of an argument to a row parameter , So the modification of row parameters , Does not affect the value of the argument The reference : The real way is to pass parameters in the form of address , Row arguments and arguments are the same object , It's just that their names are different. Changes to the row parameter will affect the value of the actual parameter explain : Pass value ...

  4. java The difference between value passing and reference passing in

    Value passed :( Formal parameter type is the basic data type ): Method call , The actual parameter passes its value to the corresponding formal parameter , The formal parameter just initializes its own storage unit content with the value of the actual parameter , It's two different storage units , Therefore, the change of formal parameter value does not affect the execution of the method ...

  5. C++ The difference between pointer and reference in

    The difference between pointers to different types is that the pointer type knows that the compiler interprets a particular address ( The address the pointer points to ) The content and size of memory in , and void* The pointer represents only one memory address , The compiler cannot pass the type and size of the object that the pointer points to , So I want to go through v ...

  6. Repost :C++ The difference between pointer and reference in

    conceptually . A pointer is essentially a variable that stores the address of a variable , Logically independent , It can be changed , Including the change of the address it points to and the change of the data stored in the address it points to . And reference is an alias , It's not logically independent , It exists with ...

  7. Talking about C++ The distinction and usage between pointer and reference in ( turn )

    Pointers and references in C++ In the common , But many beginners are not familiar with the differences between them , Let's talk about them 2 The difference and usage between the two . 1. The definition and nature of pointer and reference : (1) The pointer : The pointer is a variable , It's just that this variable stores a ...

  8. Talking about C++ The difference between pointer and reference in

    Pointers and references in C++ In the common , But many beginners are not familiar with the differences between them , Let's talk about them 2 The difference and usage between the two . 1. The definition and nature of pointer and reference : (1) The pointer : The pointer is a variable , It's just that this variable stores a ...

  9. Detailed explanation Java Soft of objects in 、 The difference between weak and virtual references

    For most objects , There will be a reference variable in the program to refer to the object , This is the most common reference method . besides ,java.lang.ref There's also... Under the bag 3 Classes :SoftReference.WeakReference and Phan ...

  10. ( Back end )Mybatis in #{} and ${} The difference of Chuanshen and # and $ Summary of the differences ( turn )

    Original address :https://www.cnblogs.com/zqr99/p/8094234.html Recently in use mybatis, Used before ibatis, On the whole, it's about the same , But there are still a lot of problems , Record again , ...

Random recommendation

  1. phpMyAdmin - error You should upgrade to MySQL 5.5.0 Or later , terms of settlement ...

    Toss your own personal website , Installed a database management tool , You should upgrade to MySQL 5.5.0 Or later ... Using demotion phpmyadmin Version of the solution : lookup phpmyadmin/libraries/com ...

  2. Linux System interruption 、 System call and scheduling overview 【 turn 】

    from :http://blog.csdn.net/yanlinwang/article/details/8169725 Copyright notice : This article is an original blog article , No reprint without the permission of the blogger . Recent learning Linux operating system , ...

  3. mysql Average the time period

    Consider the following requirements , Over a period of time , At intervals , Take an average , Take all the averages , What do I do ? Ideas : In the stored procedure , Splicing sql sentence . According to the start time and end time ,while Add a period of time at a time .DROP PROCED ...

  4. .net Determine whether the user is using a mobile device or PC

    using System.Text.RegularExpressions;// The header introduces a regular namespace // To enhance accuracy , Prevent support wap For example opera, Add operating system validation .openwave| after p ...

  5. jQuery obtain iframe Of document object

    $(function() { var result = $('#myframe').prop('contentWindow').document; console.log(result); }); this ...

  6. python Example writing (5)-- exception handling , Screenshot , Use case design

    One .python Exception handling Exception handling mechanism : 1. If an exception occurs at run time , The interpreter looks for the corresponding processing statement (handler) 2. If it cannot be found in the current function , Pass the exception to the calling function of the upper layer , See if you can handle 3. If it's on the outside ...

  7. POJ3580 SuperMemo splay Stretch the tree , Interval operation

    The question : Implement a data structure , Support for a sequence of 6 Kind of operation : The first x The number to the first y The number between each number plus D: The first x The number to the first y All numbers flip between numbers : The first x The number to the first y The number between numbers , Circulating backward c Time , ...

  8. leetcode124

    class Solution { int maxValue; public int maxPathSum(TreeNode root) { maxValue = Integer.MIN_VALUE; ...

  9. Winsock API TCP/IP Network communication

    The communication process is as follows : 1.Winsock Loading of Libraries . initialization #pragma comment(lib,"WS2_32.lib").WSAStartup() 2. Socket creation ( The server side is the monitor set ...

  10. MAC SVN Basic settings Terminal command

    extends:http://www.cnblogs.com/heiniuhaha/archive/2012/07/31/2616493.html install XCode after Mac OS X The system has built in sv ...