For more information, see the following code: a method in the database operation class.
Public function select_db ($ database = ""){
// Select a database
If ($ database! = ""){
$ This-> database = $ database;
}
If (! Mysql_select_db ($ this-> database, $ this-> link_id )){
$ This-> halt ("database unavailable". $ this-> database );
}
}
My problem is:
1. what does $ database = "" in the following code mean? Isn't it a parameter transfer? Why do we need to assign a null string?
2. if ($ database! = ""){
$ This-> database = $ database;
} What does it mean? Is the $ this-> database and $ database two different variables in it? Why is the name the same?
Reply to discussion (solution)
1. $ database = "" indicates $ database defines a default value (null character). If you call this function without passing parameters, this $ database is a null character.
2. $ this-> database is an attribute of this class, while $ database is just a variable (passed value)
$ This-> is the database the same as $ database?
I don't know where the same thing is.
1. $ database = "" indicates $ database defines a default value (null character). If you call this function without passing parameters, this $ database is a null character.
2. $ this-> database is an attribute of this class, while $ database is just a variable (passed value)
Thank you.
Let's ask another question. the source code of the project found in the book contains folders such as cache and templates. How did these folders come from? Is the template used? Do I need to download samrty for running? Can I delete these caches? Or can I directly run the php file code mentioned in those books?
If you only want to learn, you don't need to install smarty cache any more. you can create a cache for these folders, which is a cached template. you can delete the cache for some templates.
If you only want to learn, you don't need to install the smarty cache. you can create your own cache for these folders, which is a cached template and save some template caches. thank you for deleting them.