Page 1 of 1

Newbie Question - Please help

Posted: Fri Oct 24, 2003 1:33 pm
by Over40
I am just getting my feet wet so please forgive this newbie question.

Does php have a command that does the same as @checkforthis that I use with my cgi programs to check for certain conditions.

Thanks,

Over40

Posted: Fri Oct 24, 2003 1:54 pm
by microthick
In perl, @checkforthis refers to an array called checkforthis, right?

Posted: Fri Oct 24, 2003 5:57 pm
by volka
yes, and if used in a scalar context it returns the number of elements.
$ indicates a scalar (a flat value), so

Code: Select all

my @arr = qw(a b c d e f g h);
$numElems = @arr;
print $numElems, "\n";
outputs 8

php doesn't handle the variable contenxt in this way.

Code: Select all

<?php
$arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h');
echo count($arr);
?>