ID: 12689 Updated by: derick Reported By: [EMAIL PROTECTED] Old Status: Feedback Status: Closed Bug Type: Scripting Engine problem Operating System: Microsoft Windows NT PHP Version: 4.0.4pl1 New Comment: No feedback, so closing. Derick Previous Comments: ------------------------------------------------------------------------ [2001-08-10 16:15:59] [EMAIL PROTECTED] status -> feedback ------------------------------------------------------------------------ [2001-08-10 15:53:51] [EMAIL PROTECTED] Shorter example please, if you want us to take a look at your problem, you will need to take the effort of making an as-short-as possible example. >From the summary: doesn't return; and/or return $return_value; work? ------------------------------------------------------------------------ [2001-08-10 09:50:02] [EMAIL PROTECTED] I've got a problem with a little function in a test script : I want to return a string value, that exists before returning from the function. And when I try to get back this string out of the function, the value found is 0 (zero), and definitly not the one echoed in the function... You can see below the bugged script (you will have to suppress comments to run it) , with some 'echo' to localise the problem, the csv file I tried to analyse, the output obtained in my browser, and finally, a few lines commenting the problem... PHP version is 4.04pl1, running with an Apache server, on a NT4 system. <? // Here is the script /* $file="D:\\wwwroot\\e_learning\\ftp\\ga_ln_en_en.csv"; $langue="en"; //list($nbl,$abv,$idls)=get_langues(); $abv=array("fr","en","de"); // Ouverture du fichier if(isset($file)) { function get_line($f_p) { if(feof($f_p)) return ""; else {$str=addslashes(fgets($f_p,4096));echo "<BR>getline : $str";return $str;} // return addslashes(fgets($f_p,4096)); } // le deroulement de cette fonction part du principe qu'il n'y a pas d'erreur dans le csv // NB on pourrait se passer des numeros de chapitres et de pages dans le csv... function analine($lin,$tofind,&$obj,&$att,&$lan,$par=-1) { GLOBAL $langue, $abv; $match=explode(";",$lin); if(preg_match("/^\b$tofind\b/i",$match[0])) { $count=count($match); switch($tofind) { case "cours" : // c'est la premiere ligne qu'on doit analyser (les tableaux sont vides). $obj[0]=array("page_form",-1); $att[0][-1]=array("titre","language",0); $att[0][-2]=array("desc","language",0); $att[0][0]=array("page_form","text",$langue); $att[0][2]=array("page_form","text","..."); $att[0][3]=array("page_form","text",""); $l=3; foreach($abv as $ab) { // titre $arr_ti["$ab"] = $match[$l++]; // description $arr_de["$ab"] = $match[$l++]; } $lan[0]=$arr_ti; $lan[1]=$arr_de; // on renvoie 0, a savoir l'increment de l'objet ajoute dans 'obj[]' return 0; // du coup le 'break' ne sert a rien, si ce n'est impressionner le foules sur des rythmes endiables break; case "chapitre" : $cl=count($lan); $obj[$match[1]]=array("chapitre",$par); $att[$match[1]][0]=array("chapitre","text",$match[1]); $att[$match[1]][-1]=array("titre","language",$cl); $att[$match[1]][-2]=array("desc","language",$cl+1); $l=3; foreach($abv as $ab) { // titre $arr_ti["$ab"] = $match[$l++]; // description $arr_de["$ab"] = $match[$l++]; } $lan[$cl]=$arr_ti; $lan[$cl+1]=$arr_de; return $match[1]; // du fait du return, le 'break' ne sert a rien, si ce n'est impressionner le foules sur des rythmes endiables break; case "page" : $cl=count($lan); $obj[$match[1]]=array("page",$par); $att[$match[1]][1]=array("fichier","text",$match[2]); $att[$match[1]][0]=array("page","text",$match[1]); $att[$match[1]][-1]=array("titre","language",$cl); $att[$match[1]][-2]=array("desc","language",$cl+1); $l=3; foreach($abv as $ab) { // titre $arr_ti["$ab"] = $match[$l++]; // description $arr_de["$ab"] = $match[$l++]; } $lan[$cl]=$arr_ti; $lan[$cl+1]=$arr_de; return $match[1]; // du fait du return, le 'break' ne sert a rien, si ce n'est impressionner le foules sur des rythmes endiables break; case "duree" : $att[0][1]=array("page_form","text",$match[1]); return 0; break; default : return -1; } } else return -1; } //Ouverture du fichier $fp = fopen($file,"r"); $obj=$att=$lan=array(); while($line=get_line($fp)) { if($inc=analine($line,"cours",&$obj,&$att,&$lan)>=0) { $notnext=false; $nobreak=true; while($nobreak && ($not_next || $line=get_line($fp))) { echo "<BR>ligne $line<BR>"; // test pour eviter de bloquer indefiniment sur la meme ligne if($notnext) $notnext=false; // cours constitue de pages if(analine($line,"page",&$obj,&$att,&$lan,$inc)>=0) { // on recupere les pages suivantes while($line=get_line($fp) && analine($line,"page",&$obj,&$att,&$lan,$inc)>=0) {echo "<BR>ligne $line<BR>";} if(analine($line,"duree",&$obj,&$att,&$lan)>=0) // on peut quitter la boucle, car on est sense avoir fini // l'analyse du cours $nobreak=false; // else // {}// pas de duree, on peut prevoir un message d'erreur } // cours constitue de chapitres elseif($incc=analine($line,"chapitre",&$obj,&$att,&$lan,$inc)>=0) { // on recupere les pages du chapitre while($line=get_line($fp) && analine($line,"page",&$obj,&$att,&$lan,$incc)>=0) {echo "<BR>ligne $line<BR>";} echo "<BR>ligne $line<BR>"; if(analine($line,"duree",&$obj,&$att,&$lan)<0) // soit on pointe sur une nouvelle ligne de chapitre, // soit on est tombe sur un os... $notnext=true; else // on peut quitter la boucle, car on est sense avoir fini // l'analyse du cours $nobreak=false; } } // si on a trouve une duree, on peut s'arreter la if(!$nobreak) break; } } // on a fini l'analyse print_r($obj); print_r($att); print_r($lan); */ } /* There comes the content of the csv file I tried to analyse Fichier correspondant;;;Français;;English;;;;;;;;;;;; TYPE;ORDRE;FICHIER;TITRE;DESCRIPTION;TITLE;DESCRIPTION;;;;;;;;;;; cours;;;;;Lotus Notes Getting Acquainted;Lotus Notes Getting Acquainted;;;;;;;;;;; chapitre;1;;;;Introduction;Intoduction;;;;;;;;;;; page;1;ecran_intro_module_acqua_en_en.swf;;;Introduction;Introduction;;;;;;;;;;; chapitre;2;;;;Mail (GA-LN-01);The Mail database options;;;;;;;;;;; page;2;dossiers_mail_en_en.swf;;;Managing folders;Managing folders;;;;;;;;;;; page;3;simu_dossiers_mail_en_en.swf;;;Exercise;Simulation Exercise;;;;;;;;;;; page;4;taille_base_mail_en_en.swf;;;Mail database size;The size of your Mail database;;;;;;;;;;; page;5;notification_absence_en_en.swf;;;Out-of-office;Setting out-of-office mail;;;;;;;;;;; page;6;qcm_notification_absence_en_en.swf;;;Exercise;Multiple Choice Questions;;;;;;;;;;; page;7;options_notification_en_en.swf;;;Mail notification;Setting mail reception notifications;;;;;;;;;;; page;8;message_telephonique_en_en.swf;;;Phone message;Creating a phone message;;;;;;;;;;; page;9;archivage_en_en.swf;;;Archiving ;Archiving documents;;;;;;;;;;; page;10;qcm_archivage_en_en.swf;;;Exercise;Multiple Choice Questions;;;;;;;;;;; chapitre;3;;;;Databases (GA-LN-02);The Databases Options;;;;;;;;;;; page;11;afficher_en_en.swf;;;General information;General information on a database;; page;12;ouvrir_base_en_en.swf;;;Opening database;Opening and closing a database;; page;13;les_vues_en_en.swf;;;The views;The views;; page;14;select_les_vues_en_en.swf;;;Exercise;Graphical Multiple Choice Questions;; page;15;creer_liens_en_en.swf;;;Creating links;Creating links;; page;16;imprimer_database_en_en.swf;;;Printing a view;Printing a view, a document and a selection of documents;; page;17;qcm_imprimer_database_en_en.swf;;;Exercise;Multiple Choice Questions;; chapitre;4;;;;Calendar (GA-LN-04);The Calendar Options;; page;18;ouvrir_afficher_agenda_en_en.swf;;;Opening Calendar;Opening the Calendar;; page;19;creer_entrees_dans_agenda_en_en.swf;;;Calendar entries;Setting Calendar entries;; page;20;simu_entree_en_en.swf;;;Exercise;Simulation Exercise;; page;21;gerer_entrees_en_en.swf;;;Managing entries;Managing the Calendar entries;; page;22;definir_preferences_agenda_en_en.swf;;;Preferences;Setting Calendar preferences;; page;23;qcm_definir_preferences_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; page;24;ouvrir_autre_agenda_en_en.swf;;;Other Calendars;Opening someone else's Calendar;; page;25;imprimer_agenda_en_en.swf;;;Printing Calendar;Printing the Calendar;; page;26;qcm_imprimer_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; page;27;configurer_planning_disponibilite_en_en.swf;;;Free time schedule;Setting up your free time schedule;; page;28;invitations_reunions_en_en.swf;;;Meeting invitation;Creating a meeting invitation;; page;29;qcm_invitations_reunions_en_en.swf;;;Exercise;Multiple Choice Questions;; page;30;ouvrir_afficher_base_taches_en_en.swf;;;Opening To Do;Opening the To Do database;; page;31;creer_envoyer_taches_en_en.swf;;;To Do entries;Creating and working with To Do entries;; page;32;imprimer_taches_en_en.swf;;;Printing entries;Printing To Do entries;; page;33;creer_agenda_de_groupe_en_en.swf;;;Group calendar;Creating a group Calendar;; page;34;deleguer_acces_agenda_en_en.swf;;;Delegating access;Delegating access to your Calendar;; page;35;qcm_deleguer_acces_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; duree;01h15;;;;;;; // and finally the ouput I obtained with my script getline : Fichier correspondant;;;Français;;English;;;;;;;;;;;; getline : TYPE;ORDRE;FICHIER;TITRE;DESCRIPTION;TITLE;DESCRIPTION;;;;;;;;;;; getline : cours;;;;;Lotus Notes Getting Acquainted;Lotus Notes Getting Acquainted;;;;;;;;;;; getline : chapitre;1;;;;Introduction;Intoduction;;;;;;;;;;; ligne chapitre;1;;;;Introduction;Intoduction;;;;;;;;;;; getline : page;1;ecran_intro_module_acqua_en_en.swf;;;Introduction;Introduction;;;;;;;;;;; ligne 0 getline : chapitre;2;;;;Mail (GA-LN-01);The Mail database options;;;;;;;;;;; ligne chapitre;2;;;;Mail (GA-LN-01);The Mail database options;;;;;;;;;;; getline : page;2;dossiers_mail_en_en.swf;;;Managing folders;Managing folders;;;;;;;;;;; ligne 0 getline : page;3;simu_dossiers_mail_en_en.swf;;;Exercise;Simulation Exercise;;;;;;;;;;; ligne page;3;simu_dossiers_mail_en_en.swf;;;Exercise;Simulation Exercise;;;;;;;;;;; getline : page;4;taille_base_mail_en_en.swf;;;Mail database size;The size of your Mail database;;;;;;;;;;; ligne 1 getline : page;5;notification_absence_en_en.swf;;;Out-of-office;Setting out-of-office mail;;;;;;;;;;; getline : page;6;qcm_notification_absence_en_en.swf;;;Exercise;Multiple Choice Questions;;;;;;;;;;; ligne page;6;qcm_notification_absence_en_en.swf;;;Exercise;Multiple Choice Questions;;;;;;;;;;; getline : page;7;options_notification_en_en.swf;;;Mail notification;Setting mail reception notifications;;;;;;;;;;; ligne 1 getline : page;8;message_telephonique_en_en.swf;;;Phone message;Creating a phone message;;;;;;;;;;; getline : page;9;archivage_en_en.swf;;;Archiving ;Archiving documents;;;;;;;;;;; ligne page;9;archivage_en_en.swf;;;Archiving ;Archiving documents;;;;;;;;;;; getline : page;10;qcm_archivage_en_en.swf;;;Exercise;Multiple Choice Questions;;;;;;;;;;; ligne 1 getline : chapitre;3;;;;Databases (GA-LN-02);The Databases Options;;;;;;;;;;; getline : page;11;afficher_en_en.swf;;;General information;General information on a database;; ligne page;11;afficher_en_en.swf;;;General information;General information on a database;; getline : page;12;ouvrir_base_en_en.swf;;;Opening database;Opening and closing a database;; ligne 1 getline : page;13;les_vues_en_en.swf;;;The views;The views;; getline : page;14;select_les_vues_en_en.swf;;;Exercise;Graphical Multiple Choice Questions;; ligne page;14;select_les_vues_en_en.swf;;;Exercise;Graphical Multiple Choice Questions;; getline : page;15;creer_liens_en_en.swf;;;Creating links;Creating links;; ligne 1 getline : page;16;imprimer_database_en_en.swf;;;Printing a view;Printing a view, a document and a selection of documents;; getline : page;17;qcm_imprimer_database_en_en.swf;;;Exercise;Multiple Choice Questions;; ligne page;17;qcm_imprimer_database_en_en.swf;;;Exercise;Multiple Choice Questions;; getline : chapitre;4;;;;Calendar (GA-LN-04);The Calendar Options;; ligne 1 getline : page;18;ouvrir_afficher_agenda_en_en.swf;;;Opening Calendar;Opening the Calendar;; getline : page;19;creer_entrees_dans_agenda_en_en.swf;;;Calendar entries;Setting Calendar entries;; ligne page;19;creer_entrees_dans_agenda_en_en.swf;;;Calendar entries;Setting Calendar entries;; getline : page;20;simu_entree_en_en.swf;;;Exercise;Simulation Exercise;; ligne 1 getline : page;21;gerer_entrees_en_en.swf;;;Managing entries;Managing the Calendar entries;; getline : page;22;definir_preferences_agenda_en_en.swf;;;Preferences;Setting Calendar preferences;; ligne page;22;definir_preferences_agenda_en_en.swf;;;Preferences;Setting Calendar preferences;; getline : page;23;qcm_definir_preferences_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; ligne 1 getline : page;24;ouvrir_autre_agenda_en_en.swf;;;Other Calendars;Opening someone else\'s Calendar;; getline : page;25;imprimer_agenda_en_en.swf;;;Printing Calendar;Printing the Calendar;; ligne page;25;imprimer_agenda_en_en.swf;;;Printing Calendar;Printing the Calendar;; getline : page;26;qcm_imprimer_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; ligne 1 getline : page;27;configurer_planning_disponibilite_en_en.swf;;;Free time schedule;Setting up your free time schedule;; getline : page;28;invitations_reunions_en_en.swf;;;Meeting invitation;Creating a meeting invitation;; ligne page;28;invitations_reunions_en_en.swf;;;Meeting invitation;Creating a meeting invitation;; getline : page;29;qcm_invitations_reunions_en_en.swf;;;Exercise;Multiple Choice Questions;; ligne 1 getline : page;30;ouvrir_afficher_base_taches_en_en.swf;;;Opening To Do;Opening the To Do database;; getline : page;31;creer_envoyer_taches_en_en.swf;;;To Do entries;Creating and working with To Do entries;; ligne page;31;creer_envoyer_taches_en_en.swf;;;To Do entries;Creating and working with To Do entries;; getline : page;32;imprimer_taches_en_en.swf;;;Printing entries;Printing To Do entries;; ligne 1 getline : page;33;creer_agenda_de_groupe_en_en.swf;;;Group calendar;Creating a group Calendar;; getline : page;34;deleguer_acces_agenda_en_en.swf;;;Delegating access;Delegating access to your Calendar;; ligne page;34;deleguer_acces_agenda_en_en.swf;;;Delegating access;Delegating access to your Calendar;; getline : page;35;qcm_deleguer_acces_agenda_en_en.swf;;;Exercise;Multiple Choice Questions;; ligne 1 getline : duree;01h15;;;;;;; getline : */ // As you can easily remark, the function that makes problem is 'get_line()' : /* getline : page;1;ecran_intro_module_acqua_en_en.swf;;;Introduction;Introduction;;;;;;;;;;; ligne 0 */ // Those 2 lines above, are an example of the problem : there is actually a string found, but my function // strangely returns 0 ?> ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=12689&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]