function:Returns data based on the specified ID (URL)
Code:
Parse Error: Parse error, unexpected t_variable inPHPDocument1On line6
Table goods Public Function goods ($goods _id) {$sql = "Select G.goods_id,c.file_dir,c.parent_id,c.is_show A S c_is_show,g.is_show as G_is_show ". "From". Self:: $ecs->table (' goods '). "G". "Left JOIN". Self:: $ecs->table (' category '). "C on g.cat_id=c.cat_id". "WHERE g.goods_id= ' $goods _id '"; $rs = self:: $db->getrow ($sql); $arr = Array (); if (!empty ($rs)) {$arr [' savepath '] = ($rs [' g_is_show '] = = 1 && $rs [' c_is_show '] = = 1)? '/product/'. ($rs [' File_dir ']? $rs [' File_dir ']: $rs [' cat_id ']). ' /'. $rs [' goods_id ']. '. html ': '; $arr [' remoteurl '] = '/goods.php?id= '. $rs [' goods_id ']; } return $arr; }//Table category Public Function category ($cat _id, $page = 1) {$sql = "Select C.cat_id,c.file_dir,c.parent_i D,c.is_show ". "From". Self:: $ecs->table (' category '). "C". "WHERE c.cat_id= ' $cat _id '"; $rs = self:: $db->getrow ($sql); $arr = ARray (); if (!empty ($rs)) {$arr [' savepath '] = $rs [' is_show '] = = 1? '/product/'. ($rs [' File_dir ']? $rs [' File_dir ']: $rs [' cat_id ']). ' /index '. ($page > 0? '-'. $page: ') '. html ': '; $arr [' remoteurl '] = '/category.php?id= '. $rs [' cat_id ']. ' &page= '. $page; } return $arr; }//Table article public function article ($article _id) {$sql = "Select A.article_id,c.cat_id,c.file_dir,c.is_o Pen as C_is_open ". "From". Self:: $ecs->table (' article '). "A". "Left JOIN". Self:: $ecs->table (' Article_cat '). "C on a.cat_id=c.cat_id". "WHERE a.article_id= ' $article _id '"; $rs = self:: $db->getrow ($sql); $arr = Array (); if (!empty ($rs)) {$arr [' savepath '] = $rs [' is_open '] = = 1? '/article/'. ($rs [' File_dir ']? $rs [' File_dir ']: $rs [' cat_id ']). ' /'. $rs [' article_id ']. '. html ': '; $arr [' remoteurl '] = '/article.php?id= '. $rs [' article_id ']; } return $arr; } Table Public Function Articlecat ($cat _id, $page = 1) {$sql = "select c.cat_id,c.file_dir,c.parent_id". "From". Self:: $ecs->table (' Article_cat '). "C". "WHERE c.cat_id= ' $cat _id '"; $rs = self:: $db->getrow ($sql); $arr = Array (); if (!empty ($rs)) {$arr [' savepath '] = '/article/'. ( $rs [' File_dir ']? $rs [' File_dir ']: $rs [' cat_id ']). ' /index '. ($page > 0? '-'. $page: ') '. HTML '; $arr [' remoteurl '] = '/article_cat.php?id= '. $rs [' cat_id ']. ' &page= '. $page; } return $arr; }}
Usage:
$arr = Urlpath::goods (1024x768);p Rint_arr ($arr);
In addition:There is an error at the beginning, can't write like this? procted $db = $GLOBALS [' db '];
question:
One: I want to use Urlpath::goods ($goods _id) to get the specified URL and static address,
How can I use the common $db and $ecs without initializing this class in the class URLPath?
Two: Is my writing a bit of a problem? ~ Why is there an error in the other place? It seemed possible to write like this before.
Reply to discussion (solution)
A class variable cannot be declared with the value of a variable, and an additional schema function __construct is required to assign a value
Upstairs, that's right.