Topic: unkown number of arguments (Read 914 times)
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6441
39470 credits Members referred : 374
It's time to use PHP5!
« on: Jun 12, 2006, 02:42:50 PM »
Hello,
I have to write a function where the number arguments is dynamic. Is the use of an array the only way to handle this?
example:
Code:
<?php $string = "<a href=\"/{FOLDER}/script.php?lang={LANG}\">some text</a>"; $language = "nl"; $dyn_val = array("folder"=>"some_folder", "lang"=>$language); // this array can hold more or less elements
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6441
39470 credits Members referred : 374
It's time to use PHP5!
« Reply #4 on: Jun 12, 2006, 11:07:34 PM »
I have actually all this messages in my classes:
Code:
<?php $msg[33] = "Hello,\r\n\r\nthe new e-mail address must be validated, click the following link:\r\n".$host.$this->login_page."?id=".$this->id."&validate=".md5($this->user_pw)."&language=".$this->language."\r\n\r\nkind regards\r\n".$this->admin_name; $msg[34] = "There is no e-mail address for validation."; $msg[35] = "Hello,\r\n\r\nEnter your new password next, please click the following link to enter the form:\r\n".$host.$this->password_page."?id=".$this->id."&activate=".$this->user_pw."&language=".$this->language."\r\n\r\nkind regards\r\n".$this->admin_name; $msg[36] = "Your request is processed and is pending for validation by the admin. \r\nYou will get an e-mail if it's done."; $msg[37] = "Hello ".$this->user_full_name.",\r\n\r\nThe account is active and it's possible to login now.\r\n\r\nClick on this link to access the login page:\r\n".$host.$this->login_page."\r\n\r\nkind regards\r\n".$this->admin_name; $msg[38] = "The confirmation password does not match the password. Please try again."; $msg[39] = "A new user..."; $msg[40] = "There was a new user registration on ".date("Y-m-d").":\r\n\r\nClick here to enter the admin page:\r\n\r\n".$host.$this->admin_page."?login_id=".$this->id; $msg[41] = "Validate your e-mail address..."; // subject in e-mail
I want to store them in a database for easier access and translations. You seen a lot of them are very different. This function will act as kind of parser. The {VALUE} stored in the database is easy to recognize by not programmers during translations
I think about the same, but I need to find a solution that non prgrammers (translations agencies) can handle this kind of text without breaking the code:
Code:
There was a new user registration on ".date("Y-m-d").":\r\n\r\nClick here to enter the admin page:\r\n\r\n".$host.$this->admin_page."?login_id=".$this->id;
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6441
39470 credits Members referred : 374
It's time to use PHP5!
« Reply #10 on: Jun 13, 2006, 11:11:16 AM »
thats the point where I cam back to my snippet, the question was more about to give arguments to this function I read something about function overload, but this is not supported in PHP(4) right?