How can PHP be used to automatically display a price request button for products with a price of 0 in an online shop?

When products in an online shop have a price of 0, PHP can be used to automatically display a price request button instead of showing the price as 0. This can be achieved by checking the product price value and conditionally displaying the price or the request button based on that value.

<?php
// Assuming $productPrice is the variable containing the product price value
if($productPrice == 0) {
    echo '<button>Request Price</button>';
} else {
    echo 'Price: $' . $productPrice;
}
?>