0

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:

Click the image to enlarge

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.

0

Variable Rules – C vs PHP

Here is my first post about C programming language which I decided to learn this summer. Today I compare the variable declaration rules between C and PHP. The main difference between C and PHP’s variable declaration process is that C’s variable name must be declared at the beginning of the code as well as its type, whereas PHP creates variables on the fly without indicating variable type. In C, variable name must be declared uniquely within the current code, except the same name can be declared inside the functions. This is different from PHP. Thanks to its dynamic variable type, a variable name can be used as a number and a string depending what’s the value inside the variable. The variable naming rules for C is the same as PHP. It also doesn’t allow to place digits first of the variable name. I also learned that the length of a variable name in C should not be longer than 31 characters. I never heard of this rule in PHP. However, I never used more than 10 characters for the PHP variable names. I will try to apply my 10-character policy to C once I have a real C programming project. I’m looking forward to programming with C and play around with some open source code when I understand C programming language a little more.