php

Started on the old forum in April 2010 · view the original in the archive · old links redirect here

28 replies · 1,547 views · started 16 years ago · 1 min read

10 participants
crazybrumi Super moderator Principal · 1,064 posts #1

why do so many people use echo etc in there php code for lines that dont require this, surley this is just more load on the server why not just use basic html this was the server dosnt do the rendering instead the browser does it therefore reducing load on server am i right people?

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

subzero Super moderator Fellow · 3,954 posts #2

Yes. but you lessin the echo then it will be ok

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

CreativityKills Lead · 833 posts #3

Echo statements r d least things to give performance boost wen optimizing ur php software / script. Pay attention to simple coding rules and u'll be okay. Maybe we should discuss these rules sumtime.

Mysterio Lead · 630 posts #5

She said: <?echo $she;?> !

<? if ($answer == "yes") { $he = "me too"; } else { $he = "oh sh!t"; } ?> He answered: <?echo $he;?>!

Why all this? Server will say: Please, why me?

mysterio.al - programming is a functional art

CreativityKills Lead · 833 posts #6

Mysterio now thats horrible coding!

She Said: <?php echo $she ?>!<br/>
He Answered: <?php echo ($answer == 'yes') ? 'Me too' : 'Oh Sh!t'; ?>

you c wot i mean? Little ugly coding here n there = performance drop aka server load.

CreativityKills Lead · 833 posts #7

Also ive noticed that putting if statements before foreach helps performance.

$results = mysql_fetch_array(mysql_query($some_query));
// Bad
foreach($results as $result)
{
// loop me
}

// Good
if(count($results) > 0)
{
 foreach($results as $result)
 {
   // Loop me
 }
}
crazybrumi Super moderator Principal · 1,064 posts #8

mobileGIGS wrote: Echo statements r d least things to give performance boost wen optimizing ur php software / script. Pay attention to simple coding rules and u'll be okay. Maybe we should discuss these rules sumtime.

no i ment for a basic level here not all the members in ere are compitent in doing things as others are so therfore i kept my example simple. Theres a whole deal of factors that could be discussed and if you folk want to we can do.

but yes going back i dont see the point why

echo "sitename : $sitename"; when it would be better to do it as this

sitename : <? print($sitename) ?>

therfore only making conttact to the server when needed. the rest would just be html and not in echo " ";

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

Mysterio Lead · 630 posts #9

you right mobileGIGS, i wrote it horrible to tell that not all time mixing php and html is good.

mysterio.al - programming is a functional art

djlee Developer · 224 posts #11

theres a number of simple things you can do, most of which wont make much difference unless you run time test scripts (these are fundamentality there to expose a flaw in a design and very rarely would you ever meet the conditions in a timed test, and timed tests depend on more things that just the raw code so ideally they should be performed 100's of times for accurate results ina randomised order).

Anyhows if your that interested,

use echo not print use fetch_assoc or fetch_row not array, this creates duplicate data in RAM use ternary statements where applicable NOT if conditions, such as when settings up dynamics in a text string for example

echo 'welcome '.(isset($user) ? $user['name'] : 'Guest').', please enjoy your stay';

use single quotes not double quotes when echoing anything that you dont need to input variables into Only break out of PHP for worthy lengths of code, making the interpreter mess around searching for tags that are next to each other really isnt nice just to get it to skip 2 or 3 html tags Learn to use a god damn switch, elseif's going down 100's of lines just aint good coding

subzero Super moderator Fellow · 3,954 posts #16

ELSE is abit faster then case or else if(user =

Faster to use is else if(user ==

i don't know why but it seems faster to load in 8 less the = or case

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

djlee Developer · 224 posts #17

completely wrong, you have no reliable data from that page, you dont know what sample data was used and you dont know the conditions under the tests were run.

As i said before nearly everything i mentioned will have little impact on non-realtime environments and only become noticeable under extreme testing that will never equate to anything you will possibly code in your lifetime.

using a 100 elseif's for smilies e.c.t. isnt wrong as such, its just ugly and bad programming, hence why i never gave a reason for this in my other post as speed is just negligable, but if you handed your code of 100 elseif's to a good programmer they'd probably throw it back at you unless you had a good reason for using it (i.e. complex conditioning).

@sub: you should learn a bit more of php tbh. since when was case a valid substitute for else ? ofcourse else is gonna be faster because those two things perform completely different thing. else vs default would at least have been a valid challenge.

Oh and never trust online resources for speed results, a quick google of "switch vs if php" revealed a source that said switch was 25% quick than if's completely contradicting the previous posters link. Without knowing the full conditions and data set that was run on a test you can't rely on other sources (they will never give you a full spec of their test as everything you can possibly think of from hardware, running processes, messenger being open, type of php module used all has a direct impact on the resultset)

subzero Super moderator Fellow · 3,954 posts #18

i know php alot ... and else is faster also much more error free 😉

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

djlee Developer · 224 posts #19

so you've

  1. compared two completely different functions
  2. provided some half baked statement that you've given no example, evidence or any indication whatsoever to prove you actually know what your talking about

So i would beg to differ on your php skills until your able to select two functions (or atleast parts of said function) that perform an equal function

subzero Super moderator Fellow · 3,954 posts #20

djlee i dont need to show they are not the same but they do the same thing.

  1. You think i dont know nothing when i have 10 scripts that is made by me.
  2. To show what case is your a retard djlee i guesting you think you know about php all you doing it arugering with ppl...
  3. You need to learn PHP as far you bump in my topic script short urls you given ppl errors with your little code and you say i don't know nothing ?? lol your the one need to sit down and learn php

GO SELECT FirstName, LastName, TelephoneNumber, 'When to Contact' = CASE WHEN TelephoneSpecialInstructions IS NULL THEN 'Any time' ELSE TelephoneSpecialInstructions END FROM Person.vAdditionalContactInfo;

You can see here case do come slower and needs to know... case is not so old as well that come in php 2.5.4

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Sign in to reply.

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close