| View previous topic :: View next topic |
| Author |
Message |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Mon Aug 18, 2008 5:22 am Post subject: php - OB |
|
|
edit :
I meant when echoing html using php that's all i meant. Sorry for not making this clear.
<?php
ob_start();
echo '<html><head /> <body bgcolor="black" text="gold"><p>At worlds collide</p>';
header('Location: http://www.google.se');
?> _________________
Intel over amd yes.
Last edited by NINTENDO on Thu Aug 21, 2008 7:13 am; edited 3 times in total |
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Wed Aug 20, 2008 10:28 am Post subject: |
|
|
you cant modify the header, last i checked at least. before you send html it sends the header information to the browser. once its sent, the browser expects whatever was in the header.
i use a template engine i wrote, so this isnt something i ever need to worry bout. no html is sent till the end of my scripts which leaves me the ability to change the header when ever i want.
im not sure what your trying to do or why you would need to do this, but ob_start() is a good idea if your not using templates. no html is sent to the browser then till you spew it out. meaning the header hasnt been sent yet leaving you the ability to change it if you need to. |
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Aug 20, 2008 2:29 pm Post subject: |
|
|
| NO it wont work. If you try it will give u header has already been sent error. Cause u already sent the packet to the client so how are u gonna get it back? |
|
| Back to top |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Wed Aug 20, 2008 3:54 pm Post subject: |
|
|
| As soon as you do echo(), printf() or any other function which prints text (an empty line too afaik) it will set the normal HTML header. |
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 21, 2008 12:45 am Post subject: |
|
|
if you get a error in php saying
your headers were already sent..
that means.. you used a function to redirect to another page or something.. a html function even with
meta http-equiv=REFRESH or something
anyways that just means you have to run php code first.. then run html after.. but yah u could do html prints in php as long as its printed from php page which is included by another php page.. so php ran first u could echo out the html or print it which ever. This all i remember when i coded in php a few years ago.
just post your code I could help you out _________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Thu Aug 21, 2008 1:13 pm Post subject: |
|
|
headers location url means redirect to another page..
you get that error cuz u trying to put in HTML.. but you got redirected so
you have to run the headers code first then any echo code after why u try to put in some html.. when its just gets redirected to google anyways u wont see your code. _________________
|
|
| Back to top |
|
 |
DeviantGeek Newbie cheater
Reputation: 0
Joined: 30 Apr 2006 Posts: 20 Location: 127.0.0.1
|
Posted: Thu Aug 21, 2008 7:45 pm Post subject: |
|
|
| Naablet wrote: | I meant when echoing html using php that's all i meant. Sorry for not making this clear.
<?php
ob_start();
echo '<html><head /> <body bgcolor="black" text="gold"><p>At worlds collide</p>';
header('Location: *omgawd i cant post urls yet!*');
?> |
this will work if you want to send them to google. since the output buffer is capturing the html, nothing is sent to the users browser which means the header hasnt gone either. but normally nobody needs to spew out html then do a header(location) because you do all your checking before you start any html lol |
|
| Back to top |
|
 |
|