'how to add variable link in html

i have a remote php file located on a server

https://webserver.com/file.php

and i have several images in html file on another server that are linked through

<div class="apps">
    <a href = "file.php?type=1"><img src="https://anysite.com/image.jpeg" alt="image" border="0"></a></br>
    logo
</div>

i want to replace the main link with a variable and add it to my images.

should appear link the following:

<div class="apps">
    <a href = "$variable?type=1"><img src="https://anysite.com/image.jpeg" alt="image" border="0"></a></br>
    logo
</div>

and the final link of the image will be:

https://webserver.com/file.php?type=1

Anyone can help please?

the html code is as follows:

<html> 
    <head> </head>
    <?php 
    var $variable = "https://webserver.com/file.php";
    ?>
    <body>
    <div class="apps">
    <a href = "$variable?type=1"><img src="https://anysite.com/image.jpeg" alt="image" border="0"></a>
    logo
</div>
<div class="apps">
    <a href = "$variable?type=2"><img src="https://anysite.com/image2.jpeg" alt="image2" border="0"></a>
    logo
</div>
</body>
</html>


Solution 1:[1]

It's PHP, not Javascript question. You try something like this?

<div class="apps">
    <a href = "<?php echo $variable; ?>?type=1"><img src="https://anysite.com/image.jpeg" alt="image" border="0"></a></br>
    logo
</div>

EDIT:

complete example:

<?php 
    $variable = "https://webserver.com/file.php";
?>
<html> 
    <head> </head>
    <body>
    <div class="apps">
    <a href="<?php echo $variable; ?>?type=1"><img src="https://anysite.com/image.jpeg" alt="image" border="0"></a>
    logo
</div>
<div class="apps">
    <a href="<?php echo $variable; ?>?type=2"><img src="https://anysite.com/image2.jpeg" alt="image2" border="0"></a>
    logo
</div>
</body>
</html>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1