English 中文(简体)
php 称“非方法功能”不能接触所有类别成员时的类别范围
原标题:php class scope when calling a non-method function not accessing all class members
  • 时间:2010-03-19 17:59:25
  •  标签:
  • php

因此,使用单独功能的Im从使用所要求类别的人的类别中选取。 本职能

function catalogProductLink($product_id,$product_name,$categories=true) {
    //This is the class that the function is called from
    global $STATE;
if ($categories) {
    //The $STATE->category_id is the property I want to access, which I can t
    if (is_array($STATE->category_id)) {
        foreach($STATE->category_id as $cat_id) {
            if ($cat_id == 0) continue;
            $str .= "c$cat_id/";
        }
    }
}
$str .= catalogUrlKeywords($product_name). -p .$product_id. .html ;
return $str;
}

这里是职能呼吁,该职能是在统计学会内部进行的。

$redirect = catalogProductLink($this->product_id, $tempProd->product_name, true, false);

The object that I need access to is the $STATE object that has been declared global. Prior to this function call there are lots of public properties populated, but when I look at the $STATE object within the function scope it loses all the properties but one, product_id. The property that matters for this function is the category_id property, which is an array of category id s.

我不禁要问,为什么我无法接触到美国统计局目标的所有公共财产,以及我如何获得这些财产。

问题回答

做些什么? 页: 1 这种声音像一种可怕的设计——BTW。 如果global 是框架的一个组成部分,RUN!

或者,你只能增加一个可选择的参数,以进行分类。 也许不是有<条码> 类别=true,而是有<条码> 类别<> 采用多种类别:





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签