Reputation: 5676
In my first 3 days in coding my homework. I successfully did it. But when I got to school, my code have a problem. I have an ajax form and some php functions.
Here is an example.
$i = 1
if($i == 1) {
echo "yes";
}
else {
echo "no";
}
The answer in my sample is true. But in my case it's always false. And I notice the ajax requests that the returned message was
// new line
// new line
yes
// new line
That's why it's being false. What is the cause of this? I didn't put any new line in my code.
Upvotes: 0
Views: 133
Reputation: 43810
if your code doesn't include any html, simply open:
<?php
you don't need to close it. This will help you eliminate any whitespace or new lines
Upvotes: 1
Reputation: 78971
If you want the easy way out of it, try this
ob_clean();
echo "yes";
exit;
Upvotes: 0
Reputation: 400962
You must have newlines somewhere :
Note : make sure you don't have anything outside the <?php ... ?>
tags : it would get sent to the browser.
Upvotes: 4