$str = "/property/details&id=202&test=123#tab-6p";
$position = strpos($str,"&");
echo substr_replace($str,"?",$position,1);
Using substr_replace we can replace the occurrence of first character only in string.
as & is repeated multiple times but only at first position we have to replace & with ?