如何从“变量”设置HTML中元素的宽度

I want to set the width of a progress bar I have, but since HTML doesn't really have variables I tried this:

<span class="bar" style="width:<?php echo $goal_percent . '%'; ?>"></div>

I know it's wrong, I just don't know how I would do something like this?

Edit: Here is more of the code I'm using:

                            <?php
                            $goal_percent = $goal / 100;
                            $goal_percent = $goal * 100;
                            if($goal_percent == 0)
                            {
                            $goal_percent = 1;
                            }
                            $goal_percent = 50;
                            ?>

                            <span class="progress progress-success progress-striped active" style="margin-bottom: 9px;">
                        <span class="bar" style="width:<?php echo $goal_percent; ?>%"></span>

I'm setting goal percent to 50 after just for testing just in case something else was going wrong with the math. Still not working.

This code Will work. I just test it:

<html>
    <head><title>Test</title></head>
    <body>
        <?php $goal_percent=50; ?>
        <div class="bar" style="width:<?php echo $goal_percent; ?>%"></div>
    </body>
</html>

As long as $goal_percent is a valid int/float variable. Like @LawrenceCherone mentioned:

<span class="bar" style="width:<?php echo $goal_percent; ?>%"></span>