user2764854
user2764854

Reputation: 1

unexpected T-string in line 8

i get the following error: Parse error: syntax error, unexpected T_STRING in /home/a5836790/public_html/3.1 opdracht.php on line 8

from script:

<?php
$vars = array(true, 10, 19.95, 'hoi');
$var = array2(1 is van het type, 10 is van het type, 19.95 is van het type, text is van het type);
foreach ($vars as $waarde) {
    foreach ($var as $waardes) {
        echo gettype($waarde), "\n";
        echo $waardes, "\n"; 
    }
}
?>

Can any1 help me out on this issue,

i cant figure it out.

Upvotes: 0

Views: 137

Answers (3)

Md. Sahadat Hossain
Md. Sahadat Hossain

Reputation: 3236

try this

<?php
$vars = array(true, 10, 19.95, 'hoi');
$var = array('1 is van het type', '10 is van het type', '19.95 is van het type', 'text is van het type');
foreach ($vars as $waarde) {
    foreach ($var as $waardes) {
        echo gettype($waarde). "\n";
        echo $waardes. "\n"; 
    }
}
?>

array2 is not valid array function. It will be array

if value of array is string it must be include with quote ('').

Upvotes: 1

IMSoP
IMSoP

Reputation: 97708

The line it's complaining about is this one:

$var = array2(1 is van het type, 10 is van het type, 19.95 is van het type, text is van het type);

It's not entirely clear what you are trying to with that line, but assuming you want to create an array, the keyword is always array, not array2; array2 could be the name of a function, but I don't think that's what you meant.

You also have a series of phrases in that array which aren't quoted as strings. This is the syntax error PHP is complaining about - it's getting as far as is and not knowing what it means. You need to put quotes around each set of words you want to be a separate string, so I think what you want is this:

$var = array('1 is van het type', '10 is van het type', '19.95 is van het type', 'text is van het type');

Upvotes: 0

ciruvan
ciruvan

Reputation: 5213

Use dots instead of commas for concatenation.

echo gettype($waarde). "\n";
echo $waardes. "\n";

And this line...

$var = array2(1 is van het type, 10 is van het type, 19.95 is van het type, text is van het type);

...well, there's so much wrong with it, I don't know where to begin.

Upvotes: 0

Related Questions