Page 1 of 1
php macro?
Posted: Fri Jun 25, 2004 2:02 pm
by alanchinese
hi, in my php program i need to do the following repeatly:
$newObject = new COM("comObject") or die("comObject could not be started");
is there a way for me to create a macro so that i only need to do the following:
$newObject = $macroComObject;
thankx a lot.
from alan.
Posted: Fri Jun 25, 2004 2:06 pm
by feyd
you could make a function that performs it..
Code: Select all
<?php
function newObject($name)
{
return new COM($name) or die("{$name} could not be started");
}
$newObject = newObject("comObject");
?>
Posted: Fri Jun 25, 2004 2:06 pm
by magicrobotmonkey
Code: Select all
<?php
function macroComObject(){
return new COM("comObject") or die("comObject could not be started");
}
$newObject = macroComObject();
?>
Posted: Fri Jun 25, 2004 2:08 pm
by feyd
heh
Posted: Fri Jun 25, 2004 2:11 pm
by magicrobotmonkey
heh is right
Posted: Fri Jun 25, 2004 8:30 pm
by alanchinese
returning from a function is a good idea, but this is not what I wanted.
i want "macro" to replace some repeated strings + (part of ) statements combination, just like what C provided.
Posted: Fri Jun 25, 2004 11:45 pm
by feyd
there is no macro functionality like that in php that I'm aware of.
you could potentially use eval to create something like it.. but this is a hack at best...
Posted: Sat Jun 26, 2004 3:17 pm
by Weirdan
alanchinese wrote:
i want "macro" to replace some repeated strings + (part of ) statements combination, just like what C provided.
doesn't your editor support macros?
