Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 06-20-08   #11 (permalink)
PC Gamer
 
NessTheHero's Avatar
 
intel nvidia

Join Date: May 2008
Location: Pittsburgh
Posts: 324
Blog Entries: 2

Rep: 30 NessTheHero is acknowledged by some
Unique Rep: 0
Folding Team Rank: 191
Hardware Reviews: 1
Trader Rating: 0
Default

Quote:
Originally Posted by Safetydan View Post
Because a single = is an assignment operator, not a comparison operator, parsers can't generally decide ambiguity (should this = be an assignment or a compare?) easily
To further elaborate on this, PHP is running the first assignment in the first if statement, and because it completes successfully, returns a true on the assignment, which gets evaluated by the if statement and so it runs the first block.

But if you're doing huge comparisons like that, use the switch case structure that Dismounted posted. Saves time, it's easier to read, and more flexible.
__________________
I have four words for you...
DEVELOPERS DEVELOPERS DEVELOPERS DEVELOPERS
Five thousand, two hundred, and eighty points per day


Next upgrades: 150 GB Raptor; 24" Monitor; 9800 GTX 4 SLI; Q6600; Auzentech Prelude;
* Waiting on Sandy Bridge *

System: Legendary Awesome
CPU
C2D E4600 2.88GHz OC'd 20% through BIOS
Motherboard
ASUS Striker Extreme
Memory
G.Skill DDR2 800 4GB
Graphics Card
XFX GeForce 9800 GTX(G92) 512MB
Hard Drive
160, 250, 1000
Sound Card
SoundMax HD Audio card
Power Supply
600W
Case
Antec Twelve Hundred
CPU cooling
Zalman Copper heatsink
GPU cooling
Stock
OS
Vista Home Premium x64
Monitor
Two 19 inch monitors
NessTheHero is offline I fold for Overclock.net   Reply With Quote
Old 06-20-08   #12 (permalink)
Programmer
 
Dismounted's Avatar
 
intel ati

Join Date: Oct 2007
Location: Melbourne, Australia
Posts: 339

Rep: 41 Dismounted is acknowledged by some
Unique Rep: 0
Folding Team Rank: 540
Hardware Reviews: 2
Trader Rating: 0
Default

Quote:
Originally Posted by wolf_08 View Post
You could just add <?= not <?php its much easier.
This is something you shouldn't do, and I consider this bad coding practice. What is someone has short_tags disabled? Your script won't run then. Always use <?php, for compatibility reasons. It is not that much harder to type "php", is it?

Someone may have noticed that in my previous post, I used single quotes instead of double. This is because using double quotes will instruct PHP to parse the string for any variables, and because of this, it is slightly slower.

You may also notice that I used echo() in place of print(). This is because echo() is slightly faster because print() needs to return a boolean (true/false) value.

Although these speed "increases" are so small they are not noticeable normally, it is a good habit to write code that runs as fast as possible. It may be just me, as I work on fairly large PHP projects - every little bit counts.
__________________
System: Powered By Xeon
CPU
Intel Xeon X3320 (45nm Quad)
Motherboard
ASUS Maximus "Rampage" Formula SE
Memory
4GB (4x1GB) Crucial Ballistix Tracer DDR2-800
Graphics Card
HIS HD 4850 IceQ 4 Turbo 512MB
Hard Drive
WD Raptor 150GB, WD Caviar SE16 500GB + 250GB
Sound Card
ASUS SupremeFX II
Power Supply
Corsair HX-620
Case
Cooler Master RC-690
CPU cooling
Thermalright Ultima-90I
GPU cooling
IceQ 4 Cooler
OS
Windows Vista 64-bit
Monitor
Samsung 226BW
Dismounted is offline I fold for Overclock.net   Reply With Quote
Old 06-24-08   #13 (permalink)
Programmer
 
metala's Avatar
 
intel ati

Join Date: Aug 2006
Location: Blagoevgrad, Bulgaria
Posts: 686
Blog Entries: 5

Rep: 26 metala is acknowledged by some
Unique Rep: 0
Trader Rating: 0
Default

Quote:
Originally Posted by Dismounted View Post
This is something you shouldn't do, and I consider this bad coding practice. What is someone has short_tags disabled? Your script won't run then. Always use <?php, for compatibility reasons. It is not that much harder to type "php", is it?

Someone may have noticed that in my previous post, I used single quotes instead of double. This is because using double quotes will instruct PHP to parse the string for any variables, and because of this, it is slightly slower.

You may also notice that I used echo() in place of print(). This is because echo() is slightly faster because print() needs to return a boolean (true/false) value.

Although these speed "increases" are so small they are not noticeable normally, it is a good habit to write code that runs as fast as possible. It may be just me, as I work on fairly large PHP projects - every little bit counts.
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.

True
Unfortunately, this is one of the easiest ways to make a template.
I just hate this <?echo($a)?> .. It's times better <?=$a?>... Well, from now on, I'll use my template engine in making the templates.
__________________
- Marin Ivanov -
Debian worshipper
Link of the month: Phlame - PHP Web Server with PHP support (Linux Alpha 0.1.41 released)
My: Clubs, Photo, Web projects, CheapTechs,
Quote:
Originally Posted by /usr/games/fortune
You would if you could but you can't so you won't.

System: Korpus
CPU
Core 2 Duo E6750@1.144V stable
Motherboard
Asus P5K
Memory
4 x 1GB Kingmax @ 1066MHz DDR2
Graphics Card
Sapphire Radeon HD 2600 XT 256MB GDDR3 850/810
Hard Drive
320GB Seagate ST3320620AS
Sound Card
24bit ALC883 7.1+2 & ATI's HDMI
Power Supply
FORTRON PNF-350
Case
Generic brand
CPU cooling
Stock
GPU cooling
Stock
OS
Debian Lenny + Windows XP
Monitor
19" Philips 19S7FS
metala is offline   Reply With Quote
Old 06-25-08   #14 (permalink)
Overclocker in Training
 
theRemix's Avatar
 
intel nvidia

Join Date: Apr 2006
Posts: 298

Rep: 29 theRemix is acknowledged by some
Unique Rep: 0
Trader Rating: 0
Default

actually, it is all a matter of personal preference.

and i personally prefer to do things the (well we can't call them "standard" so) "long-hand" way.

<?php echo $var ?>

only as a practice (Even in my own very small usage cases to keep the habit) because most (or most that i've worked with) open source projects keep this standard.

whatever tickles your phpickle
__________________
screenshot of BFG-c2d on gentoo linux
http://remixtechnology.com/view/bfg-...deo-screenshot

System: BFG-c2d
CPU
E6600
Motherboard
BFG nForce 680i
Memory
2gb pny ddr800
Graphics Card
BFG 8800GTS
Hard Drive
3x160gb seagate sataII
Sound Card
Intel hda
Power Supply
BFG 650W
Case
Super LanBoy
CPU cooling
Tuniq Tower 120
OS
GNU Linux Gentoo 2.6.19
Monitor
Samsung 225BW 22" LCD
theRemix is offline   Reply With Quote
Old 06-29-08   #15 (permalink)
Security Sleuth
 
Pooping^fish's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: oklahoma
Posts: 832

Rep: 36 Pooping^fish is acknowledged by some
Unique Rep: 0
Trader Rating: 0
Default

Ahaha, remix. That was quite the humorous PHP pun. Took me a second to see that.
On a side note, darn I wish I knew what you guys do. =(
__________________
Quote:
"O, hai! Want som pRon? Dwnlod ths kodk frst. Its teh bst pRonz ever, we prmis." -GibbyGano
Proud Member of the Linux Gaming Community
I am your friend.

System: CSS Pwner
CPU
e6400 @ 3.2
Motherboard
p5n-t 780i
Memory
2gb ocz @ 900
Graphics Card
8800gtx flashed to 621/2ghz
Hard Drive
7200.10 250gb
Sound Card
X-FI Extreme Music
Power Supply
750w Toughpower
Case
Lian li pc-65
CPU cooling
TR u120 Extreme
GPU cooling
stock
OS
Ubuntu, Vista ult. SP1
Monitor
24" Westy
Pooping^fish is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 02:36 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.16479 seconds with 9 queries