1
我在問自己,是否可以投射一個字符串變成另一種類型,如PHP - 來自變量的鑄造類型
$type = "int";
$foo = "5";
$bar = ($type) $foo;
並在$酒吧=== 5
我在問自己,是否可以投射一個字符串變成另一種類型,如PHP - 來自變量的鑄造類型
$type = "int";
$foo = "5";
$bar = ($type) $foo;
並在$酒吧=== 5
是的,有對於一個內置的功能:
$type = "int";
$foo = "5";
$bar = settype($foo, $type);
謝謝!正是我在找什麼。 – Xehanort