php-general Digest 8 Aug 2005 15:07:51 -0000 Issue 3613

Topics (messages 220190 through 220223):

Re: A question on the term CFG.
        220190 by: wayne
        220191 by: Jasper Bryant-Greene

Re: shell_exec("zip.. ?
        220192 by: Burhan Khalid

Re: mkdir, Shared Hosting?
        220193 by: hitek
        220195 by: Esteamedpw.aol.com

Re: Setting up a new box from scratch?
        220194 by: Burhan Khalid
        220197 by: Norbert Wenzel

How to start a global variable within a function?
        220196 by: Wong HoWang
        220198 by: Jasper Bryant-Greene
        220199 by: Wong HoWang
        220200 by: Wong HoWang
        220203 by: Wong HoWang
        220204 by: Wong HoWang
        220206 by: Wong HoWang
        220211 by: M Saleh EG
        220214 by: Miles Thompson
        220216 by: Jochem Maas

dynamically selecting a function
        220201 by: Thomas
        220202 by: Norbert Wenzel
        220205 by: Burhan Khalid
        220207 by: Thomas
        220208 by: Norbert Wenzel
        220212 by: M Saleh EG

About Get_meta_tags()
        220209 by: Jimmie
        220210 by: Paul Waring

Re: Average time spent on a page
        220213 by: Jay Blanchard

Inherit Methods
        220215 by: Norbert Wenzel
        220217 by: Jochem Maas
        220219 by: Norbert Wenzel
        220220 by: Jochem Maas
        220221 by: Edwin Barrios
        220222 by: M Saleh EG

Re: Performace and segfault errors with Php5 + Apache 1.3.x + linux-2.6.x
        220218 by: Edwin Barrios

parallel execution of php code?
        220223 by: Martin van den Berg

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hi Jasper,
I thought about this and so I did a grep on "autoload"
and came up empty. Is there a different way of checking
for the magic function?
Thanks

On Mon, 2005-08-08 at 08:24 +1200, Jasper Bryant-Greene wrote:
> Or if it's PHP 5 they might be using an __autoload() magic function 
> which gets called whenever a class that isn't declared is instantiated. 
> That function could be require()ing another file.
> 
> Jasper
> 
> 
> Chris wrote:
> > That isn't created by PHP, it must be declared in the code somewhere.
> > 
> > Maybe there is an auto_prepend_file set?
> > 
> > http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
> > 
> > Chris
> > 
> > wayne wrote:
> > 
> >> First, I'm new to PHP. I have a script that
> >> has a piece of code that looks like this -
> >> require_once($CFG->wwwroot . '/lib/mylib.php');
> >> My question is this, I'm trying to find out
> >> how the class $CGF was initiated.There are no
> >> include or require statement before the statement.
> >> Is $CFG a global variable? If how does it get
> >> initiated?
> >> Tnaks.
> >>
> >>  
> >>
> > 
> 

--- End Message ---
--- Begin Message --- Well if you're using 4.3.10 as you said in your other post then __autoload is not supported anyway. A grep on autoload would've turned it up.

I'm assuming you've tried a grep for "CFG" to find the declaration?

Jasper


wayne wrote:
Hi Jasper,
I thought about this and so I did a grep on "autoload"
and came up empty. Is there a different way of checking
for the magic function?
Thanks

On Mon, 2005-08-08 at 08:24 +1200, Jasper Bryant-Greene wrote:

Or if it's PHP 5 they might be using an __autoload() magic function which gets called whenever a class that isn't declared is instantiated. That function could be require()ing another file.

Jasper


Chris wrote:

That isn't created by PHP, it must be declared in the code somewhere.

Maybe there is an auto_prepend_file set?

http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file

Chris

wayne wrote:


First, I'm new to PHP. I have a script that
has a piece of code that looks like this -
require_once($CFG->wwwroot . '/lib/mylib.php');
My question is this, I'm trying to find out
how the class $CGF was initiated.There are no
include or require statement before the statement.
Is $CFG a global variable? If how does it get
initiated?
Tnaks.









--- End Message ---
--- Begin Message ---
Sam Smith wrote:
shell_exec("zip -r ddd ddd"); // don't work

safe_mode off, works from command line php. What could it be?

You need to give the full path to zip.

--- End Message ---
--- Begin Message --- More than likely, your host has safe mode on. Safe mode is a pain in the ass if you need to create directories or write to files, but seems to be the defacto standard for shared hosts using php.

[EMAIL PROTECTED] wrote:


Thanks, but I've tried that when I first got the Error message, it still gave me the error. Thanks though!

In a message dated 8/7/2005 1:29:26 A.M. Central Standard Time, [EMAIL PROTECTED] writes:

Open up your FTP client and log into your website, then change the permissions on your folder so that the apache process has write access to it. Its really hit and miss depending on your setup.

The sure fire way (but highly insecure) way is to change the permissions to the directory in question to 777.

A better  solution would be 755, but it may not work.

Try it, and see what  you get.






--- End Message ---
--- Begin Message ---
 
Thanks, I thought that might have been it - but It's not... I wrote a  
support ticket and - now - I'm able to use mkdir as long as the  Directories 
are 
chmoded to 755+   :)
 
thanks to all who helped!
 
 
In a message dated 8/8/2005 2:16:12 A.M. Central Standard Time,  
[EMAIL PROTECTED] writes:

>More  than likely, your host has safe mode on. Safe mode is a pain in the  
>ass if you need to create directories or write to files, but seems to  be 
>the defacto standard for shared hosts using  php.


 

--- End Message ---
--- Begin Message ---
Brian Dunning wrote:
Hey all -

I have an unused Pentium box here, recent, well loaded with RAM and HD. I want to turn it into a LAMP box. Never done that before; is there a preferred one-stop-shop installer CD or anything (easy - knock on wood)? It would be nice to end up with some kind of decent web GUI for admin.

As others have responded, any linux distribution will come with packages to install the different components of LAMP. The 'easy' part depends on which distribution you choose, and how it does the install process.

Most people recommend Madrake (now called Mandriva), Fedora (RedHat) or SuSE. Ubuntu is another one I see mentioned quite often. I would recommend you that you give the 'LiveCD' versions of these distributions a try before you decide to install one permanently. I've heard from other users that ubuntu's install process is very easy, but of course, YMMV.

Also note that almost all of the distributions I mentioned here are designed for desktop use, which means that unless you customize the install, you will get a complete desktop system (including X, and one of KDE or Gnome). This is fine if you want to use the PC as a workstation from time to time. However, if you just want it to be a server (ie, no monitor, no keyboard, just plug it into the network) then you will have to customize the install process to uncheck those items that you will not need (like X, for example).

For your other part -- webmin is a great utility for managing servers if you are uncomfortable with the shell. Your distribution will probably have a package (or RPM) for it, so just install it as per your distribution's install process.

Hope this helps,
Burhan

--- End Message ---
--- Begin Message ---

Brian Dunning wrote:
Hey all -
...
is there a preferred one-stop-shop installer CD or anything (easy - knock on wood)?

the really easy way is to use xampp [1]. I know it is easy, because even I got that thing working within a few minutes. but mind the security of the box, xampp is configured for developing applications, not for exposing the server to the net.

[1] http://www.apachefriends.org/en/

--- End Message ---
--- Begin Message ---
as title, how to start a global variable within a function?

--- End Message ---
--- Begin Message ---
<?php
$someGlobalVariable = 'foo';

function myFunction() {
        global $someGlobalVariable;

        // do stuff with $someGlobalVariable
}
?>

Jasper

Wong HoWang wrote:
as title, how to start a global variable within a function?

--- End Message ---
--- Begin Message ---
as title, how to do that? 

--- End Message ---
--- Begin Message ---
as title, how to do that?

--- End Message ---
--- Begin Message ---
but, I mean I haven't start the global variable BEFORE the function is 
called...
"Jasper Bryant-Greene" <[EMAIL PROTECTED]> 
wrote:[EMAIL PROTECTED]
> <?php
> $someGlobalVariable = 'foo';
>
> function myFunction() {
> global $someGlobalVariable;
>
> // do stuff with $someGlobalVariable
> }
> ?>
>
> Jasper
>
> Wong HoWang wrote:
>> as title, how to start a global variable within a function? 

--- End Message ---
--- Begin Message ---
but, I mean I haven't start the global variable BEFORE the function is
called...
"Jasper Bryant-Greene" <[EMAIL PROTECTED]>
wrote:[EMAIL PROTECTED]
> <?php
> $someGlobalVariable = 'foo';
>
> function myFunction() {
> global $someGlobalVariable;
>
> // do stuff with $someGlobalVariable
> }
> ?>
>
> Jasper
>
> Wong HoWang wrote:
>> as title, how to start a global variable within a function?

--- End Message ---
--- Begin Message ---
That is something like:
<?php
fubction myfunc(){
    $foo = 'bar'; // I want this $foo can access outside
}
myfunc();
echo $foo;
?>

Can I write like this?

<?php
function myfunc(){
    $GLOBALS['foo'] = 'bar';
}
myfunc();
echo $foo;
?>
"Jasper Bryant-Greene" <[EMAIL PROTECTED]> 
wrote:[EMAIL PROTECTED]
> <?php
> $someGlobalVariable = 'foo';
>
> function myFunction() {
> global $someGlobalVariable;
>
> // do stuff with $someGlobalVariable
> }
> ?>
>
> Jasper
>
> Wong HoWang wrote:
>> as title, how to start a global variable within a function? 

--- End Message ---
--- Begin Message ---
simply,
$GLOBALS['varname']=some_value;
 M Saleh EG
+971-50-4779817

 On 8/8/05, Wong HoWang <[EMAIL PROTECTED]> wrote: 
> 
> as title, how to do that?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
M.Saleh.E.G
97150-4779817

--- End Message ---
--- Begin Message ---

Fer chrissakes - just try it.
Twill either work or not.

Miles


At 06:20 AM 8/8/2005, Wong HoWang wrote:
but, I mean I haven't start the global variable BEFORE the function is
called...
"Jasper Bryant-Greene" <[EMAIL PROTECTED]>
wrote:[EMAIL PROTECTED]
> <?php
> $someGlobalVariable = 'foo';
>
> function myFunction() {
> global $someGlobalVariable;
>
> // do stuff with $someGlobalVariable
> }
> ?>
>
> Jasper
>
> Wong HoWang wrote:
>> as title, how to start a global variable within a function?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
stop posting multiples times.
and try the code.

you write:

"Can I write like this?
<?php

function myfunc(){
        $GLOBALS['foo'] = 'bar';
}
myfunc();
echo $foo;
?>"

what on godes earth stops you from sticking that in a text file
and running it? takes just as long as sticking it in an email.

<hint>YOU ARE REQUIRED TO CODE/TRY STUFF YOURSELF!</hint>.

Wong HoWang wrote:
That is something like:
<?php
fubction myfunc(){
    $foo = 'bar'; // I want this $foo can access outside
}
myfunc();
echo $foo;
?>

Can I write like this?

<?php
function myfunc(){
    $GLOBALS['foo'] = 'bar';
}
myfunc();
echo $foo;
?>
"Jasper Bryant-Greene" <[EMAIL PROTECTED]> wrote:[EMAIL PROTECTED]

<?php
$someGlobalVariable = 'foo';

function myFunction() {
global $someGlobalVariable;

// do stuff with $someGlobalVariable
}
?>

Jasper

Wong HoWang wrote:

as title, how to start a global variable within a function?



--- End Message ---
--- Begin Message ---
Hi there,

 

How can I do something like this: 

 

[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]

 

$step would be an int (I would check that before) and then I would have all
sorts of functions like step1(), step2() . etc.

 

Any ideas?

 

Thomas


--- End Message ---
--- Begin Message ---
Thomas wrote:
Hi there,

How can I do something like this:
[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]

$step would be an int (I would check that before) and then I would have all
sorts of functions like step1(), step2() . etc.

Any ideas?

Thomas

What about switch / case?

switch($step) {
 case 1:
        step1();
        break;
 case 2:
        step2();
        break;
 default:
        defaultStep();
        break;
}

--- End Message ---
--- Begin Message ---
Thomas wrote:
Hi there,

How can I do something like this:
[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]

$step would be an int (I would check that before) and then I would have all
sorts of functions like step1(), step2() . etc.

Use call_user_func().  Simple example:

function x1() { print 'x1'; }
function x2() { print 'x2'; }

$x = 1;
call_user_func('x'.$x);
$x = 2;
call_user_func('x'.$x);

--- End Message ---
--- Begin Message ---
Thanks Burhan. Is there much overhead?

Norbert: that's what I am doing now, just wanted to save some code. :-)

Thomas

-----Original Message-----
From: Norbert Wenzel [mailto:[EMAIL PROTECTED] 
Sent: 08 August 2005 11:18 AM
To: [email protected]
Subject: [PHP] Re: dynamically selecting a function

Thomas wrote:
> Hi there,
> 
>  
> 
> How can I do something like this: 
> 
>  
> 
> [snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]
> 
>  
> 
> $step would be an int (I would check that before) and then I would have
all
> sorts of functions like step1(), step2() . etc.
> 
>  
> 
> Any ideas?
> 
>  
> 
> Thomas

What about switch / case?

switch($step) {
  case 1:
        step1();
        break;
  case 2:
        step2();
        break;
  default:
        defaultStep();
        break;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Thomas wrote:
Thanks Burhan. Is there much overhead?

Norbert: that's what I am doing now, just wanted to save some code. :-)

Thomas

-----Original Message-----
From: Norbert Wenzel [mailto:[EMAIL PROTECTED] Sent: 08 August 2005 11:18 AM
To: [email protected]
Subject: [PHP] Re: dynamically selecting a function

Thomas wrote:

Hi there,



How can I do something like this:


[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]



$step would be an int (I would check that before) and then I would have

all

sorts of functions like step1(), step2() . etc.



Any ideas?



Thomas


What about switch / case?

switch($step) {
  case 1:
        step1();
        break;
  case 2:
        step2();
        break;
  default:
        defaultStep();
        break;
}


i thought that would be too easy ;-)

--- End Message ---
--- Begin Message ---
hmm, there is an intresting way that AFAIK only exists in PHP which is the 
variable variable and variable function.
That is you could have a string to be a function name and then make the call 
with it in the following manner:
$step=1;
$func_const_name="step";
$dyn_func=$func_const_name.$step;
 and then the function call would look like
$dyn_func(); // which would result in step1();
 How about that? isnt it so beautiful? God Bless ZEND

 On 8/8/05, Norbert Wenzel <[EMAIL PROTECTED]> wrote: 
> 
> Thomas wrote:
> > Thanks Burhan. Is there much overhead?
> >
> > Norbert: that's what I am doing now, just wanted to save some code. :-)
> >
> > Thomas
> >
> > -----Original Message-----
> > From: Norbert Wenzel [mailto:[EMAIL PROTECTED]
> > Sent: 08 August 2005 11:18 AM
> > To: [email protected]
> > Subject: [PHP] Re: dynamically selecting a function
> >
> > Thomas wrote:
> >
> >>Hi there,
> >>
> >>
> >>
> >>How can I do something like this:
> >>
> >>
> >>
> >>[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]
> >>
> >>
> >>
> >>$step would be an int (I would check that before) and then I would have
> >
> > all
> >
> >>sorts of functions like step1(), step2() . etc.
> >>
> >>
> >>
> >>Any ideas?
> >>
> >>
> >>
> >>Thomas
> >
> >
> > What about switch / case?
> >
> > switch($step) {
> > case 1:
> > step1();
> > break;
> > case 2:
> > step2();
> > break;
> > default:
> > defaultStep();
> > break;
> > }
> >
> 
> i thought that would be too easy ;-)
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
M.Saleh.E.G
97150-4779817

--- End Message ---
--- Begin Message ---
Hi, All,

    Sorry to trouble you, but I really can not handle this problem now. I
want to call get_meta_tags() function to get meta-tags which site I want to
know. I searched usage and I did like this: 

    <?php

// Call get_meta_tags to fetch meta_tags in brackets.

$tags = get_meta_tags("http://www.example.com/";);

 

    //Echo meta content

print $tags['keywords']; 

?> 

 

But an errors occurred when the page run. Some information liked this:

  Warning: get_meta_tags(): php_network_getaddresses: gethostbyname failed
in d:\apache\htdocs\meta_tag.php on line 3

Warning: get_meta_tags(http://www.pconline.com.cn): failed to open stream:
No such file or directory in d:\apache\htdocs\meta_tag.php on line 3

 

My server is Apache 1.3.27 and PHP4.4.0 that run in Windows 2000 server. 

 

I want to ask if anybody can solve the problem, thanks so much.

 

Best wishes,

Jimmie

 


--- End Message ---
--- Begin Message ---
On Mon, Aug 08, 2005 at 05:10:27PM -0700, Jimmie wrote:
> But an errors occurred when the page run. Some information liked this:
> 
>   Warning: get_meta_tags(): php_network_getaddresses: gethostbyname failed
> in d:\apache\htdocs\meta_tag.php on line 3
> 
> Warning: get_meta_tags(http://www.pconline.com.cn): failed to open stream:
> No such file or directory in d:\apache\htdocs\meta_tag.php on line 3

The first error means that PHP can't resolve the domain name
pconline.com.cn, i.e. it doesn't know what IP address that site is
hosted on. As a result, it can't connect to the site and open a file
stream to read the page you want to get the meta tags for, which is what
the second error is about. I would suggest getting up a command prompt
on the machine you are using (if this is possible) and seeing if you can
resolve the domain manually by running 'nslookup pconline.com.cn'
(without the quotes). If you can't, then there's almost certain a
problem with one of your DNS resolvers, as I can resolve the hostname
from here.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

--- End Message ---
--- Begin Message ---
[snip]
Guess what? I've googled for it and.... nothing
[/snip]


Sorry, I have to call you out on this one. I provided the very google
link that you needed and asked a couple of other key questions.

[quote]
How much time spent creating a page?
How much time spent viewing a page?
How much time the page was left open on the desktop?

http://www.google.com/search?hl=en&q=average+time+spent+on+web+page has
a list of thousands, which is nearly how many times you sent the same
e-mail to the list in 3 minutes.
[/quote]

--- End Message ---
--- Begin Message --- Is it possible to run inherited methods in the scope of the child class? In my case I have an abstract class called 'Company' and some child classes. There is a non abstract function in 'Company' which prints '$this->phoneList'. That function should be the same to all child classes, without rewritting it in every class.

I call the printing method via the child class like
$childObject->printPhoneList();
The call seems to be handed over to the parent class 'Company' which is fine. But the $this points to the phoneList of the abstract parent class. So the phoneList in the abstract class seems to be unset, since i have set the phone list in the child class.

Here's a short example, showing what I mean:

<?php

abstract class AbstractClass {

        private $var;
        
        public function printVar() {
                echo('var: ' . $this->var . '<br>');
        }

}

class ConcreteClass extends AbstractClass {

        public function __construct($var) {
                $this->var = $var;
        }
                
        public function printVarChild() {
                echo('var (child): ' . $this->var . '<br>');
        }

}

$cl = new ConcreteClass(15);
$cl->printVar();
$cl->printVarChild();
?>

Output is:
var:
var (child): 15


Has anyone an idea how to print the $var of the child, without copying the method in every child class?

thanks in advance,
Norbert

--- End Message ---
--- Begin Message ---
Norbert Wenzel wrote:
Is it possible to run inherited methods in the scope of the child class? In my case I have an abstract class called 'Company' and some child classes. There is a non abstract function in 'Company' which prints '$this->phoneList'. That function should be the same to all child classes, without rewritting it in every class.

I call the printing method via the child class like
$childObject->printPhoneList();
The call seems to be handed over to the parent class 'Company' which is fine. But the $this points to the phoneList of the abstract parent class. So the phoneList in the abstract class seems to be unset, since i have set the phone list in the child class.

Here's a short example, showing what I mean:

<?php

abstract class AbstractClass {

  ^ seeing as you are using the abstract keyword you must be using php5.
    which supports the 'parent' keyword but that is not what you want right 
now...



    private $var;

      get rid of the 'private' here and replace it with 'protected'

public function printVar() {
        echo('var: ' . $this->var . '<br>');
    }

}

class ConcreteClass extends AbstractClass {

    public function __construct($var) {
        $this->var = $var;
    }
public function printVarChild() {
        echo('var (child): ' . $this->var . '<br>');
    }

}

$cl = new ConcreteClass(15);
$cl->printVar();
$cl->printVarChild();
?>

Output is:
var:
var (child): 15


Has anyone an idea how to print the $var of the child, without copying the method in every child class?

thanks in advance,
Norbert


--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Norbert Wenzel wrote:
    private $var;


      get rid of the 'private' here and replace it with 'protected'

too stupid. I'm sorry for my question.

thank you for opening my eyes.

norbert

--- End Message ---
--- Begin Message ---
Norbert Wenzel wrote:
Jochem Maas wrote:

Norbert Wenzel wrote:

    private $var;



      get rid of the 'private' here and replace it with 'protected'


too stupid. I'm sorry for my question.

the only stupid people are those that don't make an effort - you don't
seem to fall into that category. (I don't subscribe to the 'there are no stupid
questions philosphy ;-) for instance 'Hey, Norbert - what is your name?',
that woudl be a pretty stupid question :-P)


thank you for opening my eyes.

vanilla sky :-)


norbert

--- End Message ---
--- Begin Message ---
Hi !

you have to defined protected $var.

 This is a example  where php5 OO model has a little ambiguities.
Thing a few in your  problem !, on de child class scope $var it's
private then when yo execute printVar(), you aren't executed on parent
scope you are calling a copie on child scope, then you don't have
access to $var. Only when you use parent scope throw
parent::printVar() , you realy calling the parent class instance into
your child then print result.

Then when you want to have a variable for being used on a public
inherit method you have to defined protected

On 8/8/05, Norbert Wenzel <[EMAIL PROTECTED]> wrote:
> Is it possible to run inherited methods in the scope of the child class?
>   In my case I have an abstract class called 'Company' and some child
> classes. There is a non abstract function in 'Company' which prints
> '$this->phoneList'. That function should be the same to all child
> classes, without rewritting it in every class.
> 
> I call the printing method via the child class like
> $childObject->printPhoneList();
> The call seems to be handed over to the parent class 'Company' which is
> fine. But the $this points to the phoneList of the abstract parent
> class. So the phoneList in the abstract class seems to be unset, since i
> have set the phone list in the child class.
> 
> Here's a short example, showing what I mean:
> 
> <?php
> 
> abstract class AbstractClass {
> 
>         private $var;
> 
>         public function printVar() {
>                 echo('var: ' . $this->var . '<br>');
>         }
> 
> }
> 
> class ConcreteClass extends AbstractClass {
> 
>         public function __construct($var) {
>                 $this->var = $var;
>         }
> 
>         public function printVarChild() {
>                 echo('var (child): ' . $this->var . '<br>');
>         }
> 
> }
> 
> $cl = new ConcreteClass(15);
> $cl->printVar();
> $cl->printVarChild();
> ?>
> 
> Output is:
> var:
> var (child): 15
> 
> 
> Has anyone an idea how to print the $var of the child, without copying
> the method in every child class?
> 
> thanks in advance,
> Norbert
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
*parent* keyword does not belong to PHP5 !!! It's there in PHP4 as well!

On 8/8/05, Edwin Barrios <[EMAIL PROTECTED]> wrote: 
> 
> Hi !
> 
> you have to defined protected $var.
> 
> This is a example where php5 OO model has a little ambiguities.
> Thing a few in your problem !, on de child class scope $var it's
> private then when yo execute printVar(), you aren't executed on parent
> scope you are calling a copie on child scope, then you don't have
> access to $var. Only when you use parent scope throw
> parent::printVar() , you realy calling the parent class instance into
> your child then print result.
> 
> Then when you want to have a variable for being used on a public
> inherit method you have to defined protected
> 
> On 8/8/05, Norbert Wenzel <[EMAIL PROTECTED]> wrote:
> > Is it possible to run inherited methods in the scope of the child class?
> > In my case I have an abstract class called 'Company' and some child
> > classes. There is a non abstract function in 'Company' which prints
> > '$this->phoneList'. That function should be the same to all child
> > classes, without rewritting it in every class.
> >
> > I call the printing method via the child class like
> > $childObject->printPhoneList();
> > The call seems to be handed over to the parent class 'Company' which is
> > fine. But the $this points to the phoneList of the abstract parent
> > class. So the phoneList in the abstract class seems to be unset, since i
> > have set the phone list in the child class.
> >
> > Here's a short example, showing what I mean:
> >
> > <?php
> >
> > abstract class AbstractClass {
> >
> > private $var;
> >
> > public function printVar() {
> > echo('var: ' . $this->var . '<br>');
> > }
> >
> > }
> >
> > class ConcreteClass extends AbstractClass {
> >
> > public function __construct($var) {
> > $this->var = $var;
> > }
> >
> > public function printVarChild() {
> > echo('var (child): ' . $this->var . '<br>');
> > }
> >
> > }
> >
> > $cl = new ConcreteClass(15);
> > $cl->printVar();
> > $cl->printVarChild();
> > ?>
> >
> > Output is:
> > var:
> > var (child): 15
> >
> >
> > Has anyone an idea how to print the $var of the child, without copying
> > the method in every child class?
> >
> > thanks in advance,
> > Norbert
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
M.Saleh.E.G
97150-4779817

--- End Message ---
--- Begin Message ---
Yes i'm using a lot of nested loops with __call(), because of  dom
did'nt support  parse not well formated html, i decided to develop my
html templates class iTemp, and i used a combinatios of foreach (
iterator implementention  ) and __call +__get to create a inherity
tree like dom.

But i don't undestand, why only changing the kernel from  2.6.x =>
2.4.x all my problems were solved magically ?

On 8/4/05, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> * Edwin Barrios <[EMAIL PROTECTED]>:
> > i'am developing  a web framework SifEngine (Secure Web Inteface
> > framework) that implement MVC applaying the security ideas from
> > http://phpsec.org. I'am using DomXML, Sqlite, Mcrypt and PostgreSql.
> >
> > After  of post my development on the internet ( i have been thinking
> > to post on PEAR ), i made simple tests of aplications with my
> > framework. During the implementation, i used Slackware 10.1 with
> > kernel 2.4.29 + php5.0.4 + Apache 1.3.2, with no problems. I didn't
> > detect  performace problems or segfaults by apache.  Then i decided to
> > do the same test but with kernel 2.6.10, wating that no problems
> > occur. However my expectation, on this new configuration all the
> > aplications develped with my framework, had performance issues or in
> > the worst situation produce apache forks  to be restarted, or a lot of
> > apache forks.
> >
> > i don't undestand why this occur, i try to use valigrand to verify
> > memorie lacks without results.
> 
> Are you using __call() or any of the other overloading methods? I had a
> situation several months ago where __call() was going into an infinite
> loop and causing segfaults. Once I tracked that down and fixed it,
> everything worked fine.
> 
> --
> Matthew Weier O'Phinney
> Zend Certified Engineer
> http://weierophinney.net/matthew/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
I have this piece of php-code which inserts data into a database.
Before inserting it must verify if the data is unique. The php code
looks something like:

$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";
$rows = execute( $query )
if ( $rows == 0 )
{
   /* some more processing */
  $query = "INSERT INTO mytable ...... etc etc
  execute( $query )
}

Now here is the problem: when the user enters the page, and directly
refreshes the record is inserted twice.... Is is possible that both
requests are processed simulatiounsly by the server (apache on linux)?
And can I add something like a critical section or semaphore to
overcome this problem.

Thanx,

Martin

--- End Message ---

Reply via email to