0
I have the following code:
$ws1 = file_get_contents('http://10.0.0.0:1111/bids/all/'.$obj->auction_id);
How do I include one more bar (/) after $obj->id
and put one more PHP code like this:
0
I have the following code:
$ws1 = file_get_contents('http://10.0.0.0:1111/bids/all/'.$obj->auction_id);
How do I include one more bar (/) after $obj->id
and put one more PHP code like this:
3
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 the .
to concatenate (join) two strings.
Change the variable $php2
by whatever after the bar (for example, $obj->outro_campo
).
As commented by our colleague @Valdeirpsr, there is this other 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 quotes, PHP interprets the names started by $
as variables. In the case of objects and some expressions, to disambiguate, it is necessary to use the delimiters { }
around the set.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Or else
file_get_contents("http://10.0.0.0:1111/bids/all/{$obj->auction_id}/{$php2}");
– Valdeir Psr
@Valdeirpsr added to be more complete
– Bacco