PHP – Unable to concatenate two variables while generating a php sitemap

while trying to generate dynamic sitemaps, I tried adding two variables in url path, and the line is giving me error

this is my sample line:

echo "<loc>" . $base_url . "category.php?category=" . $subFeaturedPostCatSlug . "&job=" . "$subFeaturedPostSlug" . "</loc>" . PHP_EOL;PHP_EOL;

I tried doing it like this also:

echo "<loc>{$base_url}category.php?category={$subFeaturedPostCatSlug}&job={$subFeaturedPostSlug}</loc>" . PHP_EOL;

error screenshot attached;
error screenshot attached

Any help will be appreciated, thanks in advance

>Solution :

Try this –

$str = $base_url . "category.php?category=" . $subFeaturedPostCatSlug . "&amp;job=" . $subFeaturedPostSlug . "" . PHP_EOL;
echo htmlspecialchars_decode($str);

Leave a Reply