Forum Moderators: open
else if(strcasecmp($person, $name) == 0 && $code!== $password ¦¦!empty($another_person) && $code!== $another_password )
Some of the values are taken from a form and some are taken from a database. I can already turn the form vaules into Javascript ones, but how do I make the database/php values work in Javascript?
Also, I'm guessing the question is pretty much the same in Javascript, but what of the strcasecmp function? I've looked around to see if there's a js equivalent but found nothing.
Is there Javascript resource site like php.net? Something that has the Javascript documentation.
strcasecmp(person, name) becomes:
person.toLowerCase() = name.toLower.case()
There isn't simple, direct analogue to empty [php.net]. All JS values have a Boolean evaluation. This could be analogous, except,in JS, "0" and an empty array do not evaluate to false. So
!empty(another_person) could become:
!?another_person
(note: that's 2 exclamation marks - the forum software removes 2 in a row)
for most, but not all types.
[edited by: Bernard_Marx at 2:22 am (utc) on July 5, 2007]
[mozilla.org...]
You want the Core Guide, and Core Reference. Note that there are some differences between Javacript & JScript, but you'll have to look hard to find them.
So I don't have to do anything to make the php variables work with js?For example to use $anotherperson, I just drop the $ sign and use it in a js string?
You don't need to drop the '$' sign in JS. '$anotherperson' is perfectly valid, it's just that JS convention has been to not use '$' in vars. In PHP you must. I am seeing more and more JS that uses $'s - probably because they are coding in PHP as well.
Actually, I believe that the $ sign has a structural significance in PHP that is meaningless in JS, because there is a fundamental difference in the way that identifiers are handled between the languages.
(PHP)
$a = 'foo';
$b = 'a';
echo $$b; // -> foo
Such jiggery pokery would be done differently in JS, where all "entities" can be passed around as data. Function names become variables in their containing scope. All variable names are really property names of some object.