HTML within PHP
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: HTML within PHP
I have never even seen that method. How does it work, and why would you say it bogs the server down? Is it saving all of the text server-side with that method?
			
			
									
						
							The indelible lord of tl;dr
			
						Re: HTML within PHP
i base my decission on how much php i am using when creating that part of a page.
if it is simple bits of code such as if,while,for loops, then i generally do all variable storing at the start of the page then code the rest in html.
such as
if i am working with alot of both of them then i will print the html out ad style it asthough i was typing plain html.
			
			
									
						
							if it is simple bits of code such as if,while,for loops, then i generally do all variable storing at the start of the page then code the rest in html.
such as
Code: Select all
<?php
if($isfriend == FALSE){
?>
 
 HTML HERE
<?php
}
?>
OR
<a href="<?php echo $link; ?>">link</a>
if i am working with alot of both of them then i will print the html out ad style it asthough i was typing plain html.
Code: Select all
print"
<table>
  <tr>
    <td>
      blah blah blah
    </td>
  </tr>
</table>
";
New Site Coming Soon! Stay tuned 
			
						
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: HTML within PHP
if you are saving all the text into a php variable then yes you are allocating server side memory for the variable.
			
			
									
						
										
						- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: HTML within PHP
Doh! lol I didn't even see that $output variable for some reason. Very odd technique.
			
			
									
						
							The indelible lord of tl;dr
			
						Re: HTML within PHP
Ok, so it's a performance hit doing it the way I described? Probably I wouldn't have noticed that as I develop the game :p
			
			
									
						
										
						Re: HTML within PHP
Yeah it is, but I prefer it for some situations. Another detail to note about it is that if you view the source code of the web page, it will be formatted just as you write it within the output tags, even with indents. With PHP it all just get printed on the same line, making it hard to read the source.Jackolantern wrote:Doh! lol I didn't even see that $output variable for some reason. Very odd technique.
If it's such a big issue with performance using this technique, I probably won't use it. Or is there a way to "release" the usage of memory right after processing the script?
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: HTML within PHP
If you continuously use the same variable name it really shouldn't be too bad, because you will keep writing over your last variable. It is not going to be a huge performance hit, but it does seem somewhat unnecessary. If you were trying to speed up the processing of your pages if your site got popular, that would likely be on the "to remove" optimization list if it was used often. Compared to optimizing MySQL statements, it would likely matter very little though.
			
			
									
						
							The indelible lord of tl;dr
			
						- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: HTML within PHP
I wouldn't make it a habit to make the source readable. I hate the fact people can view source. 
If you play on having hundreds+ users I would minimize the amount of variables you create.
			
			
									
						
										
						If you play on having hundreds+ users I would minimize the amount of variables you create.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: HTML within PHP
I guess I still don't understand what you mean about the source, unless you are talking about JS. In the case of JS, you can at least get a bit more protection through obfuscation, although the JS obfuscators are nowhere near as good as they are for .NET and Java. However, for PHP I am not sure what you mean. The only thing viewable through the browser's "view source" option is pure HTML generated by PHP.hallsofvallhalla wrote:I wouldn't make it a habit to make the source readable. I hate the fact people can view source. If you play on having hundreds+ users I would minimize the amount of variables you create.
The indelible lord of tl;dr
			
						Re: HTML within PHP
And it's that "view source" I was thinking about in my previous post, so the HTML looked a bit more tidy...Jackolantern wrote:The only thing viewable through the browser's "view source" option is pure HTML generated by PHP.hallsofvallhalla wrote:I wouldn't make it a habit to make the source readable. I hate the fact people can view source. If you play on having hundreds+ users I would minimize the amount of variables you create.



