Syntax Error on $cast

Can somebody tell me what is the problem with this syntax error?

Link here

In reply to rag123:

In the above example,
$sforamtf returns string name but $cast expects variable names
$cast(child_class_variable,parent_class_variable);

Yes but the code i put shd return a agent name. Its working if i have one agent but if i have multiple agents it doesn’t work.

In reply to rag123:

You have so many problems on one line of code.

  • You have an unbalanced set of parenthesis-- an extra ‘(’ and the immediate cause of your syntax error.
  • You are illegally comparing the result of a boolean expression with null
  • You cannot build variable names from a string. Why not use agent[I] directly?