[Phpmyadmin-devel] Any special reason that "require" but not "require _once" on libraries/common.inc.php

Michal Čihař michal at cihar.com
Mon May 20 14:31:27 CEST 2013


Hi

Dne Sat, 18 May 2013 01:08:28 +0800
adam <adamgsoc2013 at gmail.com> napsal(a):

> HI,
> 
> >Dne Fri, 17 May 2013 22:30:03 +0800
> >adam <adamgsoc2013 at gmail.com> napsal(a):
> >
> >> I agree with you about that. But I don't know why the file libraries/common.inc.php use "require" but not "require _once". this file will be used frequently, so use "require _once" is better.
> >> I was thinking that there must be some special reason.
> >
> >It is normally included just once, so there is no reason to check
> >this. However with testsuite this gets more complicated...
> >
> >The original motivation for using just require instead of require_once
> >was performance, because require_once was pretty inefficient before some
> >of the more recent versions of PHP.
> 
> 
> Thanks Michal. I agree with you that using "require" is for performance. and it is working for most cases.
> On our page (server_status.php),  It is working well, so it is not a problem here.

Indeed it i, because it loads common.inc.php just once.

> but you also mentioned that "However with testsuite this gets more complicated...".  I think there must be somewhere include the file:  'libraries/common.inc.php'
> so the testing of pages which include  'libraries/common.inc.php'; will fail due to require_once issue.

I'd just go with replacing require with require_once everywhere and it
should be safe and reportedly there is almost no performance gap in
current PHP versions.

-- 
	Michal Čihař | http://cihar.com | http://blog.cihar.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20130520/2c66fa31/attachment.sig>


More information about the Developers mailing list