草庐IT

External_variable

全部标签

php - undefined variable PHP 类

我正在尝试调试我创建的类。它总是中断并在日志中抛出undefinedvariable我找不到解决方案因为我不知道我做错了什么,我认为它应该工作但没有。undefined变量在erase()函数中,而不是在show()函数中classpepe{private$array=array();functionshow(){$this->erase();print_r($this->array);}functionerase(){print_r($this->array);}}$o=newpepe();$s=$o->show(); 最佳答案

php - 如果...否则发出 : removing the matched variable

我是编码新手,无法建立简单逻辑的想法..好的,我写了一个代码先看看:$mnaTotalCharectars:$c_mna";}$go[0]="January";$go[1]="February";$go[2]="March";$go[3]="April";$go[4]="May";$go[5]="June";$go[6]="July";$go[7]="August";$go[8]="September";$go[9]="October";$go[10]="November";$go[11]="December";$fo="October";$i=0;for($i=0;$i我想做的是删除

php - Doctrine DQL 无效参数编号 : number of bound variables does not match number of tokens

我在这个查询中收到错误无效的参数编号:绑定(bind)变量的数量与标记的数量不匹配。我真的没有看到问题,有什么想法吗?publicfunctiongetByPartial($q,Company$company){$query=$this->createQueryBuilder('u')->join('u.company',':company')->where('u.firstNameLIKE:q')->orWhere('u.lastNameLIKE:q')->setParameters(array('company'=>$company,'q'=>'%'.$q.'%'))->getQu

php - 使用可能 undefined variable 调用函数

如果我有如下语句:$b=empty($a)?"null":"'$a'"为了避免复制和粘贴,我想把它放在一个函数中:functionx($a){returnempty($a)?"null":"'$a'"}所以我可以这样做:$b=x($a);//$aisnotdefined,soPHPcomplains$d=x($c);//samewith$c但是我会从PHP得到一个错误,因为$a没有定义。除了使用@运算符之外,有什么方法可以实现这一点吗?编辑:我指的是调用x()时出现的错误,而不是在x()内部。您知道,您可以对任何undefinedobject执行isset()和empty(),PHP永

php - How to Capture Szimek/Signature_Pad with PHP (Capture Javascript into PHP Variable)?

我在浏览StackOverflow时发现了Szimek/Signature_Pad以使用Javascript捕获电子/数字签名。我研究过,但我仍然对如何将DATAURI捕获到变量中感到困惑。http://szimek.github.io/signature_pad/我想像这样捕获它$inputESignature=signaturePad.toDataURL(),其中signaturePad.toDataURL()是Javascript。如果需要澄清,请告诉我。对不起,如果我的要求有点含糊。 最佳答案 对于需要朝正确方向插入并发现$

php - 奇怪的行为,通过引用分配 undefined variable

我只是在探索符号表和变量容器如何与引用一起工作。我发现不会抛出“Undefinedvariable:bin...”的通知,而会。为什么? 最佳答案 来自手册:http://php.net/manual/en/language.references.whatdo.phpNote:Ifyouassign,pass,orreturnanundefinedvariablebyreference,itwillgetcreated.至于为什么,我只是推测php分配内存并将$a和$b分配给两者以查看内存中的那个位置。不过,这是一种记录在案的行为。

php - Yii 2 : Can I access a variable in a view that's rendered by another view?

在Yii2中,遵循MVC模式,Controller将某些变量传递给View。但是,有时View本身会呈现另一个View。例如,在默认生成的CRUDView中,create.php和update.php都呈现_formView:render('_form',['model'=>$model,])?>我是否可以使用Controller传递的变量来_form中的create.php?假设Controller像这样呈现它:return$this->render('create',['model'=>$model,'myVar'=>$myValue,]);现在我可以在create.php中访问$

php - Codeigniter : variables scope when calling a view from within a view. 奇数

从View中调用View时,我对变量范围感到困惑。我测试了一下,发现:如果变量最初是从Controller传递的,则无需执行任何操作来将变量从View传递到View。如果变量是在View中声明的,我必须显式地将变量从一个View传递到另一个View。(例如:$this->load->view("hoge",$data);)我觉得第二种情况有点奇怪,因为我的理解是$this->load->view()是phpinclude()的codeigniter版本,它不需要我显式传递变量。谁能猜出/阐明他们这样做的原因? 最佳答案 如果您查看L

php - AJAX/本地存储 : Is it possible to pass a JS variable to PHP?

我想知道,存放购物车的最佳方式是什么?我考虑过将产品ID存储在localstorage/sessionstorage中,然后使用AJAX从服务器检索产品。唯一的问题是我不知道如何将项目从本地存储传递到PHP...我猜这可能是不可能直接实现的,虽然我不知道如何实现它,但我想到了一种形式......这个想法是,当用户单击“添加到购物车”时,商品ID和数量将添加到本地存储中,当用户查看他的购物车时,商品详细信息(图片、名称、价格...)将从数据库。我可能会使用这个教程http://verido.dk/index.php/ressourcer/artikler/loading-and-savi

php - 菲尔康 : volt get value from array which key taken from variable

在phalcon模板引擎volt(类似于twig)中,您可以通过以下方式获取所有记录:{%forproductinproducts%}Name:{{product.name}}Description:{{product.description}}price:{{product.price}}{%endfor%}因此,在我的场景中,我正在构建一个将用于不同类型模型的crud模板。我想在此模板中实现的是此View中的每一列都不是硬编码的。所以我将要显示的列存储到一个数组中(在Controller中定义,传递给View):$cols=['name','description','price'