<?php $currency = $argv[1]; $pars = simplexml_load_file("http://www.cbr.ru/scripts/XML_daily.asp"); $value=$pars->Valute[$currency]->Value; ?> 

I run the script through the console, $ currency - the value transmitted at startup (numeric)

$ pars - parsing xml pages

$ value in the end is empty + Notice: Trying to get the property of non-object in / perl/includes/kurs.php on line 4

What is the problem?

thank

  • $currency = $argv[1]; var_dump($argv, $currency); What is the output? - Sh4dow
  • array (2) {[0] => string (10) "./kurs.php" [1] => string (1) "5"} string (1) "5" - Anton Cherepkov
  • Although this is not even the case, most likely. Check out what $pars contains. - Sh4dow 6:49
  • $ value = $ pars-> Valute [5] -> Value; Everything works fine here - Anton Cherepkov
  • I do not believe my eyes! Thank you, kind man! It all worked! - Anton Cherepkov

1 answer 1

Very strange. And if so?

 $currency = (int) $argv[1];