FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP Module Writing Help
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP Module Writing Help [message #173118] Tue, 22 March 2011 11:04 Go to next message
Lee is currently offline  Lee
Messages: 1
Registered: March 2011
Karma: 0
Junior Member
I am new to PHP modules, and trying to follow the tutorial at:

http://devzone.zend.com/article/1021#Heading5

All configures and makes well, but I am getting the following message:

Lee:hello $ cd modules/
Lee:modules $ php -r 'echo hello_world();'
PHP Fatal error: Call to undefined function hello_world() in Command
line code on line 1


My include path in php.ini is the default, so includes the current
directory, which includes the hello.so from the tutorial.

And help would be appreciated.

TIA
Lee
Re: PHP Module Writing Help [message #173119 is a reply to message #173118] Tue, 22 March 2011 11:20 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Lee wrote:
> I am new to PHP modules, and trying to follow the tutorial at:
>
> http://devzone.zend.com/article/1021#Heading5
>
> All configures and makes well, but I am getting the following message:
>
> Lee:hello $ cd modules/
> Lee:modules $ php -r 'echo hello_world();'

Try php -r echo 'hello world'


> PHP Fatal error: Call to undefined function hello_world() in Command
> line code on line 1
>
>
> My include path in php.ini is the default, so includes the current
> directory, which includes the hello.so from the tutorial.
>
> And help would be appreciated.
>
> TIA
> Lee
Re: PHP Module Writing Help [message #173120 is a reply to message #173119] Tue, 22 March 2011 11:59 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 22/03/2011 12:20, The Natural Philosopher escribió/wrote:
> Lee wrote:
>> I am new to PHP modules, and trying to follow the tutorial at:
>>
>> http://devzone.zend.com/article/1021#Heading5
>>
>> All configures and makes well, but I am getting the following message:
>>
>> Lee:hello $ cd modules/
>> Lee:modules $ php -r 'echo hello_world();'
>
> Try php -r echo 'hello world'

That's not even valid PHP code. What result do you expect?

The OP is trying to execute a PHP function defined by a custom extension
written in C.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: PHP Module Writing Help [message #173121 is a reply to message #173118] Tue, 22 March 2011 12:03 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 22/03/2011 12:04, Lee escribió/wrote:
> I am new to PHP modules, and trying to follow the tutorial at:
>
> http://devzone.zend.com/article/1021#Heading5
>
> All configures and makes well, but I am getting the following message:
>
> Lee:hello $ cd modules/
> Lee:modules $ php -r 'echo hello_world();'
> PHP Fatal error: Call to undefined function hello_world() in Command
> line code on line 1
>
>
> My include path in php.ini is the default, so includes the current
> directory, which includes the hello.so from the tutorial.
>
> And help would be appreciated.

Your extension is obviously not loaded. Your vague description suggests
that you've put the hello.so file in the same directory as your PHP code
and you're expecting that PHP will automatically load it. Read the
article again: you need to copy the file into your extensions directory
and add extension=hello.so to php.ini.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: PHP Module Writing Help [message #173122 is a reply to message #173118] Tue, 22 March 2011 12:04 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/22/2011 7:04 AM, Lee wrote:
> I am new to PHP modules, and trying to follow the tutorial at:
>
> http://devzone.zend.com/article/1021#Heading5
>
> All configures and makes well, but I am getting the following message:
>
> Lee:hello $ cd modules/
> Lee:modules $ php -r 'echo hello_world();'
> PHP Fatal error: Call to undefined function hello_world() in Command
> line code on line 1
>
>
> My include path in php.ini is the default, so includes the current
> directory, which includes the hello.so from the tutorial.
>
> And help would be appreciated.
>
> TIA
> Lee

No, the include_path is different from the extension_directory.
Include_path is for PHP source files. Extensions must be specifically
loaded in your php.ini file, and they generally go in a xxx/ext/ directory.

This is detailed in the "Building Your Extension" section (although it
is only a couple of lines on a long page).


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP Module Writing Help [message #173123 is a reply to message #173119] Tue, 22 March 2011 12:05 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/22/2011 7:20 AM, The Natural Philosopher wrote:
> Lee wrote:
>> I am new to PHP modules, and trying to follow the tutorial at:
>>
>> http://devzone.zend.com/article/1021#Heading5
>>
>> All configures and makes well, but I am getting the following message:
>>
>> Lee:hello $ cd modules/
>> Lee:modules $ php -r 'echo hello_world();'
>
> Try php -r echo 'hello world'
>

Try not opening your trap when you have no idea what you're talking about.

Oh - you wouldn't be able to say anything, would you?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with appendChild and ellipsis...
Next Topic: PHP Developers needed
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 00:27:51 GMT 2024

Total time taken to generate the page: 0.02220 seconds