Pass a Value to Multiple PHP Variables
I had been taking UMUC 411 this week, an one-week online test drive class for University Maryland University College. I was too active in the class that I didn’t have anything to write about on the blog. Now the class was over, I’m back to schedule to finish my website redesign project.
I decided that today I’ll be focused on “Follow me†section:
This section was made up by four images. The first one is RSS feed and the last three are social networks. I noticed that the title, alt, and part of the image location for social networks have the same content. Therefore I came up with the following PHP line to pass the value in the title variable into both alt and image location variables:
$image = $alt = $title;
In the above statement, because of the pass variables rule for PHP, I placed title variable to the farthest right of the equal signs and placed variables need to be distributed before the title variable which contains the original value. For instance, I assigned “Twitter†string to $title. $image and $alt would also assign “Twitter†string.
