Jump to content

what does .= do?


smartalco

Recommended Posts

where i work, they are using a set of code they got off some php script site, and one line includes '.=', that line also returns a non-fatal notice, heres the surrounding code

<?phpinclude $_SERVER['DOCUMENT_ROOT'] . '/classes/SQLManagerKiller.php';$sqlManager = new SQLManagerKiller;$depts = $sqlManager->getResults('SELECT id, department FROM perfrep_departments ORDER BY department');foreach($depts as $dept) {	$depts_html .= '<option value="' . $dept[0] . '">' . $dept[1] . '</option>';}

the error says that there is an undefined variable on line 8, im assuming that it means the $dept_html, and its because of the '.=', what does this do? or rather, what do you think its supposed to be from what you see?PS: search .=, '.=', or ".=" in google, it kills it, it doesn't even say 'no results' or the like, it literally shows nothing where the search results normally are

Link to comment
Share on other sites

That's the combination concatenate and assignment operator. It's similar to += in java script:java script:

var message = "Here is a ";message += "message.";

PHP

$message = "Here is a ";$message .= "message.";

The script is probably failing because you haven't ever defined $depts_html. You might try something like this:

$depts_html = '';foreach($depts as $dept) {	$depts_html .= '<option value="' . $dept[0] . '">' . $dept[1] . '</option>';}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...