PHP stops handling my page every time it encounters >
Moderator: General Moderators
PHP stops handling my page every time it encounters >
Hi,
I'm new to PHP, but not to programming. I have installed the latest Apache server and the latest PHP as an Apache module. It works fine, but evertime there is a greater-than (>) symbol in my PHP code, PHP stops handling the code. I don't know why this is. I was under the impression that the > must be preceded by ? for this to happen. I need to use > in my PHP code so that I can have html tags in my calls to the echo() function.
Thanks,
Beau
I'm new to PHP, but not to programming. I have installed the latest Apache server and the latest PHP as an Apache module. It works fine, but evertime there is a greater-than (>) symbol in my PHP code, PHP stops handling the code. I don't know why this is. I was under the impression that the > must be preceded by ? for this to happen. I need to use > in my PHP code so that I can have html tags in my calls to the echo() function.
Thanks,
Beau
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
class Calendar
{
private $month=array();
private $current=array();
function __construct()
{
$month["name"] = "November"; $month["number"] = 30;
}
function Display()
{
echo '<table>'; //from here on everything after the > insn't executed by PHP
echo '<tr>';
for($i=0; $i<$month["number"]; i++)
{
echo '<td>';
echo "<h2>$i</h2>";
echo '</td>';
}
echo '</tr>';
echo '</table>';
}
}
$c = new Calendar();
$c->Display();
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
This has nothing to do with that operator, instead you have undefined variables, your loop isn't evaluating because $i will always be greater than nothing.
You would have been aware of this if you had error_reporting(E_ALL); set
Instead, you need to reference your class variables
These variables will only be accessible within that method. Try
To bring the variables into class scope.. and obviously change the other instances of those variables accordingly.
You would have been aware of this if you had error_reporting(E_ALL); set
Instead, you need to reference your class variables
Code: Select all
function __construct()
{
$month["name"] = "November"; $month["number"] = 30;
}Code: Select all
function __construct()
{
$this->month["name"] = "November";
$this->month["number"] = 30;
}Hmm, I just tried that, and now PHP stopped executing after the > in $this->
I'm pretty sure that it is the > operator that is messing things up for me. I tried the following code as a test:
When I do this, the output in my browser is the following:
Any ideas?
I'm pretty sure that it is the > operator that is messing things up for me. I tried the following code as a test:
Code: Select all
<?php
echo "<p>Hello</p>";
echo "<p>World</p>";
?>As you can see, PHP stops executing after the > operator, wherever it is found in the PHP code. I'm figuring this might be a problem with my server configuration, but have no clue how to fix it. I left the default install options for Apache and PHP, using the recommended php.ini file. The only changes I made to the default Apache configuration were to load PHP as a module.Hello"; echo "
World
"; ?>
Any ideas?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: