tags:

views:

76

answers:

4

please tell me what is below code doing? is it creating array with two values or its creating to string index which will take value later?

 var $requiredValues=Array(
        'MaxResponses',
        'AvailableOnlyIndicator'
    );
+1  A: 

That code isn't valid php. This is:

$requiredValues=Array( 'MaxResponses', 'AvailableOnlyIndicator' );

That code is creating an array with two elements.

Tyler Smith
what is their invalid in that code?
Rajesh Rolen- DotNet Developer
It is valid in PHP 4
AntonioCS
@Dot Net Developer: The 'var' keyword is no longer valid in PHP5. In PHP5 you have private, public and protected. In PHP4 every property of the class was public.
AntonioCS
+4  A: 
$requiredValues=Array(
    'MaxResponses',
    'AvailableOnlyIndicator'
);

It is assigning index 0 to value MaxResponses and 1 to value AvailableOnlyIndicator.

So array with two values.

Note: var keyword won't work in you are under php 5+.

Sarfraz
Array keyword needs to be lowercased.
FractalizeR
Capitalization doesn't matter in PHP.
KramerC
agreed with Kramer :)
Sarfraz
Blanket statements are dangerous. `$var=2;print $Var;`
Mike B
@Mike B: right :)
Sarfraz
A: 

The code should be:

<?php array('MaxResponses', 'AvailableOnlyIndicator'); ?>

And the array would be:

Array
(
    [0] => MaxResponses
    [1] => AvailableOnlyIndicator
)
KramerC
A: 

It's creating an array with two values, with an automatic numeric index. Syntax is slightly off, but it should work.

gabrielk