I have the following code:
$ws1 = file_get_contents('http://10.0.0.0:1111/bids/all/'.$obj->auction_id);
How do I add another slash ( / ) after $obj->id
and put another PHP code like this:
I have the following code:
$ws1 = file_get_contents('http://10.0.0.0:1111/bids/all/'.$obj->auction_id);
How do I add another slash ( / ) after $obj->id
and put another PHP code like this:
Following the same logic:
$ws1 = file_get_contents('http://10.0.0.0:1111/bids/all/'.$obj->auction_id.'/'.$php2);
// Barra ---^
// Outra variável ---^
In PHP you use .
to concatenate (join) two strings .
Change the $php2
variable to whatever you want after the slash (for example, $obj->outro_campo
).
As commented by colleague @ValdeirPsr, there is another way to interpolate:
file_get_contents("http://10.0.0.0:1111/bids/all/{$obj->auction_id}/$php2");
Whenever a string is delimited by double quotation marks, PHP interprets names beginning with $
as variables. In the case of objects and some expressions, to disambiguate, you must use the { }
delimiters around the set.