[英]Cast variable in Zend 2
This may be a stupid question, but I need to know how to cast a variable in zf2. 这可能是一个愚蠢的问题,但是我需要知道如何在zf2中强制转换变量。
$var = (string) $id ;
How ca I do it with this kind of type : 我如何用这种类型的它做:
\MediaLayer\Argument\SelectMediaArguments
This doesn't work: 这不起作用:
$arg = (\MediaLayer\Argument\SelectMediaArguments) $var
There is no need to type cast in php. 无需在php中键入强制类型转换。
i could be wrong but ia, guesting that you want you IDE to recognize the $var az the selected class , in that case you need to use phpdoc block : 我可能是错的,但是我请客,让您让IDE识别$ var az所选类,在这种情况下,您需要使用phpdoc块:
/* @var $var \MediaLayer\Argument\SelectMediaArguments */
$var = X;
if this is not what you want please be more clear because there is not object casting in php 如果这不是您想要的,请更加清楚,因为在php中没有对象转换
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.