vendredi 15 janvier 2021

Condition multiple values php

I am writing some basic PHP code what is ages ago since i last did it. But there is something i am trying to get to work with a condition value.

The below code is working when it detects its on NL its switches the hreflang to NL and when I visit the .pro website it detects the English website.

Working example:

<?= ($qlangpreq ? '<link rel="alternate" href="https://www.site.nl' . $_SERVER['REQUEST_URI'] . '" hreflang="nl-NL">' 
            : '<link rel="alternate" href="https://www.site.pro' . $_SERVER['REQUEST_URI'] . '" hreflang="en-GB">'); ?>

Now I want to add a third option for https://www.site.de however i get an error that this is not possible. Below the example i tryed so far:

<?= ($qlangpreq ? '<link rel="alternate" href="https://www.site.nl' . $_SERVER['REQUEST_URI'] . '" hreflang="nl-NL">' 
            : '<link rel="alternate" href="https://www.site.pro' . $_SERVER['REQUEST_URI'] . '" hreflang="en-GB">' 
            : '<link rel="alternate" href="https://www.site.de' . $_SERVER['REQUEST_URI'] . '" hreflang="de-DE">'); ?>

This is bugging me for some hours now how can we accomplish what I want using this expression.

Aucun commentaire:

Enregistrer un commentaire