Assign Multi Vars to the same value in PHP
Sometimes, but not all that often, we have to assign multiple variables to the same initial value.
we can do this easily in PHP with the following code:
<?php
$var1 = $var2 = $var3 = $var4 = 'some_value';
?>
It may look a little odd but its very simple - all we are doing is assigning the first variable to the value of the second variable, and so on and so forth, then assigning the last variable to the actual value you want all your vars to be.
I have used this many a time were i have to set multiple vars to null before processing.
Written by Arazmus
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Did you know?
PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#