'iframe refuses to acknowledge my php string

I can get the echo to work and the minute I put the php sting in the iframe it shows up blank. The result is <iframe src="//galleryPage.php> echo result is "2021DeepFreeze"

   <?php $file = pathinfo(basename(__FILE__), PATHINFO_FILENAME); ?>
        <iframe src="/<?php $file ?>/galleryPage.php" style="width:100%; height:1000px;"  
        </iframe>
php


Solution 1:[1]

First of all, you forgot to add a ">" to the iframe tag. Right now the tag is <iframe . The second issue is that you forgot to echo the value "$file". So instead of <?php $file ?> try <?php echo $file; ?> or <?= $file ?> <?= is shorthand for echoing a value.

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 Rob