|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
What does the *= do? (PHP question)
What does the *= mean or do?
include ("config.php"); include ("include.php"); include ("lang.php"); session_start(); $c *= 1; // <<<---- What does the *= part of the variable do? if ($c == 0) { $c = 1; }; $sql = mysql_query("SELECT name, title, description, pages, ref FROM {$prefix}categories WHERE id = $c"); $current_category = mysql_fetch_array($sql, MYSQL_ASSOC); if (($c > 1) & !$current_category["name"]){ header("Location: {$dir}index.php"); }; if (!$current_category["name"]) { $current_category["name"] = "Directory Search"; }; if (!$current_category["title"]) { $current_category["title"] = $current_category["name"]; }; if (!$current_category["description"]) { $current_category["description"] = $current_category["name"]." ".$current_category["title"]; }; $last_category = false; $ref = $c; Last edited by jdkarns : January 31st, 2004 at 11:35 PM. Reason: Change title to say PHP question |
|
#2
|
|||
|
|||
|
Hello,
*= is an assignment operator to multiply while assigning. Here's an example: PHP Code:
The final value of $b is 10, since b*a == 2*5 == 10. This is the same as doing: PHP Code:
It's just a shortcut. You can also do: += (for addition assignment) -= (for subtraction assignemnt) /= (for division assignment) In your code, $c is being multiplied by 1, and the result is being stored back in $c. A bit of a strange thing to do if you ask me, but whatever floats your boat ![]() Hope that helps! |
|
#3
|
|||
|
|||
|
Thank you very much!
bbodien,
That does help 100%. I have been reading a book called Beggining PHP 4 by wrox. Although it's a good book it stays microscopic in scope so long that you cant see the big picture. I understand what they show in each example of syntax and working with forms etc. at the time. But, it is very difficult to see how to work with all the things they show you (as a whole). Again Thanks alot! Thank you Sean Karns |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > What does the *= do? (PHP question) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|