Just started my first PHP book

Hi All,

I have Larry Ullmans PHP book and am just experimenting with something to see how it works.

Here is what I am trying to do within the same page

<?php $result = “This is a test” ?>

<!–Some html–>

<?php echo “$result” ?>

When I run this I get an undefined variable error…grrrr

Well, not 100% that this would produce an undefined variable, but you are missing the semi-colon after each PHP statement.

<?php $result = "This is a test"; ?>
<?php echo "$result"; ?>

There is nothing in the code above that would produce an undefined error. So unless some other code is triggering this error, or one of your variable names is different (remember they’re case sensitive), then the above has no reason to output an error.

@cpradio, omitting the last semicolon before the closing PHP tag is optional, so it would not be the cause of this (or any) error.

Partially why I prefixed it, as if that were the problem, it should have produced a syntax error.

The error should tell you exactly which variable is undefined. What is the entire error message?