class
"Product"に定数を作成すると、この定数をProduct :: idのほかのクラスで使用でき、すべてがうまくいきます。 :-)
<?php
class Product
{
const id = "4325536";
}
...
しかし、私はconstのにURLから値を取得しようとすると、何も動作:
<?php
class Product
{
const id = $_GET['product'];
}
...
私は、オブジェクトにURLから値を取得できますか?
'' 'constructor'''の' 'define(name、value)' 'を使用してください。 http://php.net/manual/en/function.define.php –
あなたは定数があなたが探しているものは確かですか?あなたは静的なクラスメンバーがほしいと思うようです。http://stackoverflow.com/questions/3818333/how-do-i-access-static-member-of-a-class – rypskar