PHP object clone function that works both for PHP4 and PHP5
algis
Developing PHP applications that should work smooth on any PHP engine version or configuration, I need to invent some code tricks sometimes. One of the common things for me is to get a copy of an object. With PHP4 by default things are passed by value, alhough in PHP5 this behaviour has been changed and by default variables (objects) are passed by reference. It may cause unwanted modification of an object. So I wrote this small nice function to get a copy of an object (clone object) to work as expected in both PHP4 and PHP5:
function cloneObject( &$object ){
// CHECK IF WE IN PHP5 THEN USE THE "clone" THING
if( preg_match("/^5./", PHP_VERSION) ){
$code = '$return = clone $object;';
eval( $code );
}
else {
// ELSE IN PHP4 JUST PASS IT BY VALUE
$return = $object;
}
return $return;
}
Nice and simple, ehhBacitracin zinc ointment
Allegra goodman
Benefit of multivitamins
Basic electricity
Pyrimethamine
Depakote bipolar
Neomycin antibiotic
Cogentin medication
Cheveux minoxidil
Alesse acne
Diclofenac sodico
Clotrimazole cream usp 1
Arthrotec medication
Metronidazole side effects
Buy combivent
Lodine side effects
Avandamet 2 1000
Fluoxetine withdrawal
Cymbalta duloxetine
Trazodone weight gain
Clonidine adhd
Plendil
Xanax side effects
Tussionex ext rel sus medeva
Hydrochlorothiazide irbesartan tablet
B2 riboflavin vitamin
Tramadol and acetaminophen
Hydrocodone overnight
Deferoxamine
Dulcolax tablet
Addiction diphenhydramine
Generic avandia
Dextromethorphan dose hydrobromide
Low estrogen symptom
Relafen side effects
Tobramycin
Hydroxyzine hcl 25mg
Meridia order
Gift massage mineral oil
Generic hyzaar
Cheap flonase
Buy norvasc
Mevacor lovastatin
Green tea caffeine
Phenylephrine pseudoephedrine
Diltiazem cd
Toprol xl
Tamoxifen synthesis
Toprol xl 50mg
Leukocyte estrace
Vytorin for cholesterol
Soma carisoprodol
Quinine sulphate
Benefit of multivitamins
Naprosyn medication
Diovan medication
Nicorette inhalers
Medicine pravachol
Metformin information
Metronidazole vaginal gel
Avodart drug effects more side
Percocet 512
Generic norvasc
Belladonna phenobarbital
Novo sertraline
Apo amitriptyline
Cortisone shot
Scopolamine
Gentamicin side effects
Ativan dosage
Gabapentin side effects
Casanthranol
Piroxicam
Estrogen replacement
Septra ds
Effects of taking hydrochlorothiazide
Iodine potassium iodide
Attorney celebrex
Accutane recall
Seroquel overdose
Action class olanzapine
Food high in potassium
Ditropan xl side effects
Breast cancer arimidex
Provigil review
Famvir dosage
Ativan drug
Prevacid vs prilosec
Description on metformin
Losartan and hydrochlorothiazide
Drug levaquin
Fioricet
Effects minoxidil side
Simvastatin
Mobic 15mg
Keflex used for
Levoxyl overdose
Ionamin and info
Drug keppra
Generic naprosyn naproxen
Hydrochlorothiazide and diabetes
Effects femara side
Generic inderal la
Ephedrine vasopro
Allopurinol hypersensitivity
Antidepression levodopa
Hydralazine side effects
Exelon merger
Effects side vancomycin
Belladonna video
Triamcinolone acetonide cream
Omnicef 300mg
Buspar anxiety
Dopamine receptors
Buy codeine online
Paroxetine hci
Red valerian
Methimazole
Norfloxacin side effects
Neurontin weight gain
Dianabol side effects
Klonopin vs xanax
Fosamax danger
Effects pm side tylenol
Butoconazole
Long term effects of prednisone
Methenamine
Company ethanol
Darvocet info
Chantix
Acne elidel
Atarax for anxiety
Prozac weight loss
Cytomel synthroid
Zocor patent
Arimidex price
Flomax avodart
Skelaxin medication
Buy cheap fioricet
Chloroquine
Gen fluconazole
Pancuronium
Flovent inhaler side effects
Cramp leg pains quinine
Neomycin and polymyxin b sulfates
Chlorpropamide
Lexapro alcohol
Norgestrel and ethinyl estradiol
Cortisone shot acne
Lindane
Posted in PHP Application Development |
May 30th, 2008 at 7:44 am
[…] Sometimes it is need to clone objects in PHP4 but PHP4 does not have method clone. Algis Alekna on his blog posted very simple solution for this situation. Developing PHP applications that should work smooth on any PHP engine version or configuration, I need to invent some code tricks sometimes. One of the common things for me is to get a copy of an object. With PHP4 by default things are passed by value, alhough in PHP5 this behaviour has been changed and by default variables (objects) are passed by reference. […]