Welcome Guest, Not a member yet? Register   Sign In
passing URI based variable and variable inside class
#1

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,
Reply
#2

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;
Reply
#3

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB