Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72950 invoked from network); 19 Aug 2014 09:44:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2014 09:44:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=zxcvdavid@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zxcvdavid@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.180 as permitted sender) X-PHP-List-Original-Sender: zxcvdavid@gmail.com X-Host-Fingerprint: 209.85.192.180 mail-pd0-f180.google.com Received: from [209.85.192.180] ([209.85.192.180:35767] helo=mail-pd0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/B3-55441-77C13F35 for ; Tue, 19 Aug 2014 05:44:24 -0400 Received: by mail-pd0-f180.google.com with SMTP id v10so9390959pde.39 for ; Tue, 19 Aug 2014 02:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-type; bh=qS8ekLhLj9Tk6WJOdFfnYLcv5VwLVBVSTQVHXORLtUs=; b=EDW0/ioXBgLjg/BgLbHc0O57bedYKoEphyG5hA4zRpRcZTmxj9wgMEVOtRl8OZAKSL rx5sLHKbRtiG2LKjtg0GVaSLunLoHN/mRhfs7XVPXM4QTBZPH5J/ILnE176fXfiAlMGr m3XnwAvFnk/EsUnRSdL+XxNhO40F4C5neaqf165Q2w+r6dVtO9RRVKrN8T2O5EVILgz8 X9peuLscZnuAKLrKTzlYvHZ55191bXelXAEQmfQVIO436zJSkAo4qhntBACEmDAGzDZ/ PmvOxz5zxEy1vwAKHoqLJGXJQlEkHkYojEwsPbezzk05w/ET8Qgrsl7W3J3OqsF4Yd2z UYog== X-Received: by 10.66.123.75 with SMTP id ly11mr42577344pab.82.1408441459281; Tue, 19 Aug 2014 02:44:19 -0700 (PDT) Received: from [10.0.45.121] ([103.14.214.22]) by mx.google.com with ESMTPSA id oz7sm28558561pdb.77.2014.08.19.02.44.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 02:44:18 -0700 (PDT) Date: Tue, 19 Aug 2014 17:44:12 +0800 To: Derick Rethans Cc: Aaron Lewis , PHP Internals Message-ID: <8FE94CB4264041109B0E6C4EA88CC9F7@gmail.com> In-Reply-To: References: <86EEE03317124B84B62883DBE41C4ADD@gmail.com> <35D406B0A53A43FEAF472D9FC8371187@gmail.com> X-Mailer: sparrow 1.6.4 (build 1178) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="53f31c6c_19b8a08e_142" Subject: =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] =?utf-8?Q?=E5=9B=9E=E5=A4=8D=EF=BC=9A_?=[PHP-DEV] How should I call a PHP function From: zxcvdavid@gmail.com (Wei Dai) --53f31c6c_19b8a08e_142 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline > On Tue, 19 Aug 2014, Wei Dai wrote: > =20 > > > On Mon, 18 Aug 2014, Wei Dai wrote: > > > =20 > > > > > I'm trying to call a function inside a module, a PHP=5F=46UNCTI= ON. > > > > > Other than zend=5Feval=5Fstringl, what's the direct way to do i= t=3F > > > > > =20 > > > > =20 > > > > Please refer to call=5Fuser=5Ffunction and call=5Fuser=5Ffunction= =5Fex. > > > > =20 > > > =20 > > > =20 > > > Actually, you need to be careful with this. If you are calling =20 > > > another PHP function in the same extension, do *not* use =20 > > > call=5Fuser=5Ffunction. Instead, create a common C function that yo= u =20 > > > can call from whereever you need to. call=5Fuser=5Ffunction(=5Fex) = is not =20 > > > fast. > > > =20 > > > =20 > > =20 > > i agree. =20 > > =20 > > here is a scenario: > > =20 > > i was wrote an extension, and i need to call some PHP function like =20 > > =E2=80=9Cstrtr (http://lxr.php.net/s=3Fdefs=3Dstrtr&project=3DPHP=5F5= =5F4)=E2=80=9D =E2=80=9C*trim=22 or =20 > > a function in another extension but it doesn=E2=80=99t have a common = C =20 > > function. However, i don=E2=80=99t want to copy the implement code in= to my =20 > > extension. > > =20 > > so, i have two options: > > =20 > > 1. copy the duplicate code into my extension, It can be fast in this = =20 > > way, but the code is not beautiful. > > =20 > > 2. call call=5Fuser=5Ffunction(=5Fex) , it=E2=80=99s slower than the = first option, =20 > > but the code is more simple and beautiful than the first option. > > =20 > =20 > =20 > or: > =20 > 3. refactor the functionality in PHP so that trim or others *can* be =20 > used in extensions. > =20 > I would not pick option 2, especially not if you're going to call this = =20 > function a lot. Calling a PHP function directly involves a lot more =20 > overhead than just calling a C-function. =20 > =20 you are right. the reason to write php extension, because we can get performance improve= ment. cheer, Wei Dai --53f31c6c_19b8a08e_142--