$var1 = 'hello';
$var2 = $var1; // In C the variable var2 is created in memory right here
$var2 = 'bye'; // In PHP the variable var2 is created in memory here, up until now it still uses the same location of memory as var1
So in general, references should only be used if you want to work with the original variable, as it does not save memory or processing time.
Wow, spoken like a true blind hater, you don't even provide arguments. Please, go check my comment above to @seacaptain and you'll find out why what you say doesn't make sense in this context...
Get used to this, with AI tooling now uncovering new vulns and getting them exploitable far faster than has ever been possible before software is going to need to be updated far more frequently.
Back in the day it may take reseachers weeks or months to do what AI can now do in hours.
Once its a threat is discovered it's weaponsized far more quickly, meaning you simply can't be waiting 2, 3, 4 weeks to deploy a patch, it needs to be patched immediately.
Going to be interesting handling this in the enterprise space where traditionally patching has been steady, but very staged (and rightly so up until now), that is going to have to change.
You don't need to "close all browser sessions constantly" or wait for updates to install. The updates download in the background while you use the browser, without interrupting you, they install automatically the next time you launch the app. And they install very fast (depending on your storage speeds, of course), you have to wait at most 2-3 extra seconds, if any.
Seems like you haven't used Edge in a loooooooong time...
Segra 1.6.0 by Razvan Serea
Segra is a free, open-source OBS-powered game recorder offering fast gameplay capture, instant clips, AI highlights, deep game integration, and seamless uploads—perfect for gamers, streamers, and content creators. Lightweight, fast, zero bloat.
Segra key features:
Automatic Game Recording: Begin capturing gameplay the moment your game launches, with zero manual setup.
Instant Clipping: Save important moments instantly using a customizable hotkey—perfect for highlights, montages, or quick shares.
Segra AI Highlights: Let Segra automatically detect kills, assists, deaths, and key events to generate polished highlight reels without manual editing.
Gameplay Uploads: Upload recordings and clips directly to Segra.tv for fast sharing and cloud access.
Deep Game Integration: Enjoy advanced game-data tracking across hundreds of supported titles, enabling smart highlight generation and stat-informed clipping.
High-Performance Capture: Record up to 4K at 144 FPS using OBS-powered technology with minimal performance impact, supporting NVENC, AMD VCE, and custom quality controls.
Segra Editor: Edit recordings easily with timeline controls, segment management, and event-based navigation to build the perfect clip.
Customization Options: Adjust hotkeys, output formats, storage paths, codecs, capture quality, and performance settings for a tailored recording experience.
Segra 1.6.0 changelog:
Recording: Added HDR support.
Grand Theft Auto: Added game integration for deaths (FiveM and RAGE MP supported).
Highlights: Added customizable padding for highlights.
Replay Buffer: Added a shockwave visual effect when a replay buffer clip is saved.
Audio: Increased the maximum sound effects volume from 100% to 200%.
Hotkeys: Fixed hotkeys not triggering while unrelated keys were held.
Installer: Added code signing to verify publisher identity, branded the installer, and reduced OS security warnings.
OBS: Updated the supported OBS version to 32.1.2.
Download: Segra 1.6.0 | 74.4 MB (Open Source)
View: Segra Homepage | Github | Screenshot
Get alerted to all of our Software updates on Twitter at @NeowinSoftware
Question
balupton
It seems that a lot or even most php programmers just jumped in and never read the manual or even know basic syntax...
The ones I see all the time are:
Not checking variable existence by just doing
instead of the correct
which will not return a notice exception
Reference: http://au3.php.net/manual/en/language.variables.php
Using short tags
instead of the proper
which will run on many more servers
Reference: http://php.net/manual/en/language.basic-syntax.php
Also the misuse of double quotes
should be
which saves processing time
Reference: http://php.net/manual/en/language.types.st...g.syntax.single
Those are just some of the most common ones.
So what i'm asking is:
Why didn't you know this stuff if you didn't before hand?
Or if you did know this, then why do you think things like this are so ignored?
Note:
The option "I thought I did until now." should read "No, I'm a professional developer."
The option "No." should read "No, I'm a unprofessional developer."
-------------------
This thread has kinda turned into a tips thread, so here are a collection of tips that have been collected so far.
Single quotes vs Double quotes
https://www.neowin.net/forum/index.php?show...amp;p=588249172
Switch statements VS if then else statements
switch ($var) { case $option1: break; case $option2: break; default: break; } // is faster than if ( $var == $option1 ) { } elseif ( $var == $option2 ) { } else { }Thanks to redFX for reminding us of that:
https://www.neowin.net/forum/index.php?show...amp;p=588271991
If then else statements VS ternary statements
if ( false ) { echo 'true'; } else { echo 'false'; } // if faster than echo (false ? 'true' : 'false'); // which is faster than echo false ? 'true' : 'false';Also applies for $var =, instead of echo. Thanks to redFX for that:
https://www.neowin.net/forum/index.php?show...amp;p=588271991
Pre-Increment VS Post-Increment
This applies everywhere, so in for loops etc. Thanks to phpmozzer for that:
https://www.neowin.net/forum/index.php?show...amp;p=588271806
Loops in order of speed
for, foreach, while, do-while. Thanks to redFX for that:
https://www.neowin.net/forum/index.php?show...amp;p=588271808
Strict (===) comparison is faster than loose (==) comparison.
https://www.neowin.net/forum/index.php?show...amp;p=588271983
Instantiating classes
Thanks to http://www.php.lt/benchmark/phpbench.php
For loops and size calculations
for ( $i = 0, $n = sizeof($array); $i < $n; $i++ ) {} // is faster than for ( $i = 0; $i < sizeof($array); $i++ ) {}https://www.neowin.net/forum/index.php?show...amp;p=588249623
Variable declarations and memory
So in general, references should only be used if you want to work with the original variable, as it does not save memory or processing time.
https://www.neowin.net/forum/index.php?show...amp;p=588249172
If you know any others, feel free to post them :)
Edited by baluptonLink to comment
https://www.neowin.net/forum/topic/531433-php-do-you-know-basic-syntax/Share on other sites
39 answers to this question
Recommended Posts