Page 1 of 1

sha() - how to access this function?

Posted: Wed Jul 21, 2010 3:15 pm
by phummon
Hi everyone,

Full disclosure: I'm an experienced programming who is relatively new to PHP. Unfortunately, I'm also in a bit of a jam. In short, my boss gave me some PHP code and said, "You have to get this working by Friday." I don't have the luxury to do the proper tutorials, otherwise I wouldn't be rushing to this forum in a bit of a panic.

Here's the problem. The code I'm working with has this line:

Code: Select all

$variable1 = sha1("12345678".$user.$passwd);
When I execute, the compiler gives me this result...

Code: Select all

<br>
<b>Fatal error</b>:  Call to undefined function:  sha1() in <b>/export/qhome/dude1/script1.php</b> on line <b>38</b><br>
...which I'm interpreting to mean "I don't know what this sha() command is!" If this were C++ code (my home turf), I'd just "man sha," figure out which library I need to add, and then pop in the needed "#include ______" statement at the top of my code. That didn't work for in this case.

Does anyone have any insight?

Many, many thanks in advance!
-P

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 3:27 pm
by Jonah Bron
You might be using an older version of PHP. Do you know what version you're using?
phummon wrote:...the compiler gives me this result...
BTW, PHP uses an interpreter, not a compiler.

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 3:46 pm
by Weirdan
sha1() is a part of standard extension:

Code: Select all

weirdan@virtual-debian: /home/sam/weather$ php --rf sha1
Function [ <internal:standard> function sha1 ] {
  - Parameters [2] {
    Parameter #0 [ <required> $str ]
    Parameter #1 [ <optional> $raw_output ]
  }
}
However, it's available only since php 4.3.0:
sha1 manual page wrote: sha1
(PHP 4 >= 4.3.0, PHP 5)
If you have such ancient php you need to upgrade it first.

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 3:49 pm
by phummon
Sorry, no idea which version of PHP I'm using. I guess its an old one!

I take it sha1() should be a standard function in today's PHP compi- er, interpreters?

Many thanks!
-P

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 4:00 pm
by Weirdan
phummon wrote:Sorry, no idea which version of PHP I'm using. I guess its an old one!
php -v would tell you

Code: Select all

weirdan@virtual-debian: /home/sam/weather$ php -v
PHP 5.3.2-1 with Suhosin-Patch (cli) (built: Mar 13 2010 22:18:25)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
    with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 4:05 pm
by Benjamin
:arrow: Moved to PHP - Code

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 4:07 pm
by phummon
I see from phpinfo() that I'm running version PHP Version 4.0.3pl1. That sounds pretty ancient. :?

I think this pretty much answers my question. Many thanks to all who chipped in to help! :D

-P

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 4:27 pm
by Weirdan
phummon wrote: That sounds pretty ancient. :?
Yeah, almost 10 years old:
PHP Changelog wrote: 4.0.3
Released: 11 October 2000

Re: sha() - how to access this function?

Posted: Wed Jul 21, 2010 6:31 pm
by Jonah Bron
Older than this forum 8O