Ask a Question related to PHP Development, Design and Development.
-
386-Dx #1
variable in function parameter
Hello. Let's say I have something like this:
function aa($test) {
$a = 8;
echo $test;
}
$a = 2;
aa("a is ". ($a>5?"greater":"equal to or less"). " than 5".);
I want this to output "a is greater than 5".. how can i modify the code so
that the function parameter is evaluated inside the function?
386-Dx Guest
-
variable in an object parameter?
This may be a very simple post or may be something that shows my lack of understanding of html, but... I am trying to create an object that is a... -
session variable and URL parameter question
Hello, if anyone could help us that would be fantastic: We have created a recordset that uses as a parameter a URL parameter ( URL.Course_ID)... -
Parameter Search Using Form Variable
I have a connection to the SQL Server 2000 database and a data set made up a a collection of personnel records. I set up the data set with a... -
interpolating a variable with a request parameter
Try with $q->param("qty$i"); thereis no variable interpolation in '' but when u use "" variable interpolation works. regards, KM... -
variable as a parameter
<?php echo "<frame src=http://localhost/example.php?first=first name = top>"; echo "<frame src=http://localhost/test.php?first=first name =... -
Curt Zirzow #2
Re: [PHP] variable in function parameter
* Thus wrote 386-DX (murat@robcol.k12.tr):
[url]http://php.net/eval[/url]> Hello. Let's say I have something like this:
>
> function aa($test) {
> $a = 8;
> echo $test;
> }
>
> $a = 2;
> aa("a is ". ($a>5?"greater":"equal to or less"). " than 5".);
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt Zirzow Guest
-
Cpt John W. Holmes #3
Re: [PHP] variable in function parameter
> * Thus wrote 386-DX (murat@robcol.k12.tr):
No... you need to make $a global within the function for that change to>> > Hello. Let's say I have something like this:
> >
> > function aa($test) {
> > $a = 8;
> > echo $test;
> > }
> >
> > $a = 2;
> > aa("a is ". ($a>5?"greater":"equal to or less"). " than 5".);
> [url]http://php.net/eval[/url]
affect $a outside the function
function (...)
{
global $a;
$a = 8;
(can maybe do that in one operation, try it and see)
---John Holmes...
Cpt John W. Holmes Guest
-
Curt Zirzow #4
Re: [PHP] variable in function parameter
* Thus wrote CPT John W. Holmes (holmes072000@charter.net):
A yes, I did forget to mention that but as per requested I was>> > * Thus wrote 386-DX (murat@robcol.k12.tr):> >> > > Hello. Let's say I have something like this:
> > >
> > > function aa($test) {
> > > $a = 8;
> > > echo $test;
> > > }
> > >
> > > $a = 2;
> > > aa("a is ". ($a>5?"greater":"equal to or less"). " than 5".);
> > [url]http://php.net/eval[/url]
> No... you need to make $a global within the function for that change to
> affect $a outside the function
>
> function (...)
> {
> global $a;
> $a = 8;
>
> (can maybe do that in one operation, try it and see)
assuming they wanted the string test to be evalulated.
<snip>
I want this to output "a is greater than 5".. how can i modify the
code so that the function parameter is evaluated inside the
function?
</snip>
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt Zirzow Guest
-
386-Dx #5
Re: [PHP] variable in function parameter
Yes.
I simplified the example for clearance but what I really want is to send a
string as a parameter which includes variable names to be processed inside
the function. eval() works fine, but I'm sure there was another way.
"Curt Zirzow" <curt@zirzow.dyndns.org> wrote in message
news:20030728145202.GP93863@bagend.shire...> * Thus wrote CPT John W. Holmes (holmes072000@charter.net):>> >> > > * Thus wrote 386-DX (murat@robcol.k12.tr):
> > > > Hello. Let's say I have something like this:
> > > >
> > > > function aa($test) {
> > > > $a = 8;
> > > > echo $test;
> > > > }
> > > >
> > > > $a = 2;
> > > > aa("a is ". ($a>5?"greater":"equal to or less"). " than 5".);
> > >
> > > [url]http://php.net/eval[/url]
> > No... you need to make $a global within the function for that change to
> > affect $a outside the function
> >
> > function (...)
> > {
> > global $a;
> > $a = 8;
> >
> > (can maybe do that in one operation, try it and see)
> A yes, I did forget to mention that but as per requested I was
> assuming they wanted the string test to be evalulated.
>
> <snip>
> I want this to output "a is greater than 5".. how can i modify the
> code so that the function parameter is evaluated inside the
> function?
> </snip>
>
>
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."
386-Dx Guest



Reply With Quote

