passing URI based variable and variable inside class |
Hello,
exampler URL,-- example.com/index.php/products/shoes/sandals/123 This will pass as like below. public function shoes($sandals, $id) { echo $sandals; echo $id; } But how do we pass another variable along with URI segments? example if i declare $var = 'test' in class then how to access that in method? Thanks,
To pass a variable (a property) between methods of a class, you define them before the constructor:
public $var = 'test'; And inside the methods you can access and modify them with $this->var; Website: http://avenir.ro
In the example above as URL is example.com/index.php/products/shoes/sandals/123
Is there a way to access the ID via a $_GET ??? example: <?=$_GET['sandals']?> would print 123 |
Welcome Guest, Not a member yet? Register Sign In |