Hi all,
I have taken simple CMS script from internet
but there are such things that i dont understand them
below is the code

<?php
////////////////////////////////////////////////////////////////////////////////////////
// Class: DbConnector
// Purpose: Connect to a database, MySQL version
///////////////////////////////////////////////////////////////////////////////////////
require_once 'SystemComponent.php';

class DbConnector extends SystemComponent {

var $theQuery;
var $link;

//*** Function: DbConnector, Purpose: Connect to the database ***
function DbConnector(){

// Load settings from parent class
$settings = SystemComponent::getSettings();

// Get the main settings from the array we just loaded
$host = $settings['dbhost'];
$db = $settings['dbname'];
$user = $settings['dbusername'];
$pass = $settings['dbpassword'];

// Connect to the database
$this->link = mysql_connect($host, $user, $pass);
mysql_select_db($db);
register_shutdown_function(array(&$this, 'close'));

}

//*** Function: query, Purpose: Execute a database query ***
function query($query) {

$this->theQuery = $query;
return mysql_query($query, $this->link);

}

//*** Function: fetchArray, Purpose: Get array of query results ***
function fetchArray($result) {

return mysql_fetch_array($result);

}

//*** Function: close, Purpose: Close the connection ***
function close() {

mysql_close($this->link);

}


}
?>

here i didnt understand
what does it means

register_shutdown_function(array(&$this, 'close'));

and here what does it mean & symbol and creating array

array(&$this

Thanks for attention and in advance

Recommended Answers

All 3 Replies

thank you for attention.
i looked at the pages you have suggested, but i didnt find anythink like my example. if possible can you explain it on my example

I believe what it does is this:
Takes the variable, $this, and converts the value to binary code. So, for example, if the value assigned to $this ends up being 25, the value is converted to the binary equivalent, 11001. This value is an argument passed to the 'close' function, which is supposed to run after other processing completes (as instructed using register_shutdown_function)...

... any experts to verify or refute my analysis? ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.