Newbie Question - Please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Over40
Forum Newbie
Posts: 1
Joined: Fri Oct 24, 2003 1:33 pm

Newbie Question - Please help

Post 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
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

In perl, @checkforthis refers to an array called checkforthis, right?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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);
?>
Post Reply