New to PHP, please give me some advice! !

The following is a piece of PHP code: <?php $a=array(“name” => ($d = array(“cat”)) ,”Monday” =>( $c = array(“dog”) )); array_push($d,”Horse”,”Bird”); print_r ($a); ?> The result of the operation is: I want to know why the two values ​​”Horse” and “Bird” are not output when I use the array_push function. Acridine? How should I change it to have these two additional values? ? Thank you! ! Reply to discussion (solution) What are your $d and $c? array_push() pushes one or more cells to the end of the array (push). There is something wrong with your usage! You just pushed the elements into the $d array, not $a You print_r($d); take a look Where was it added array_push($a[‘name’],”Horse”,”Bird”);print_r ($a) ; Array ( [name] => Array ( [0] => cat [1] => Horse [2] => Bird ) [Monday] => Array ( [0] => dog ) ) Thank you two great masters for your answers! !

PHP development pos prints Chinese garbled characters, please give me some advice

I use Xinye’s xp-c230 (80mm printing). I use PHP to develop and print. The English print is OK, but the Chinese prints out garbled characters. I don’t know how to set the correct font, please give me some advice PS , my php printing code Reply to discussion (solution) Posted by mistake It’s the right place Check what format your file encoding is Check what format your file encoding is UTF-8 has no BOM format, using notepad++ software Look at the manual, can xp-c230 support UTF-8 Chinese characters? I’m afraid it can only be gbk, right? Look at the manual, can xp-c230 support utf-8 Chinese characters? I’m afraid it can only be gbk, right? The moderator is awesome. I changed it to gbk and it works really well. I love the moderator so much. Take a look at the manual, xp-c230 Can it support utf-8 Chinese characters? I’m afraid it can only be gbk, right? Moderator, can you set printing to support html code Printing format setting is a bit troublesome Not very clear , you should read the printer’s user manual (programmer’s manual) After searching, there are quite a few entries for this printer, and there may be articles…

PHP basic questions, please give me some advice

$url_array = array() for ($count = 1; $row = $result->fetch_row(); ++$count) { $url_array[$ count] = $row[0]; } I would like to ask about this code. url_array is declared as an array. The for loop is a bit unclear. The for Why does the loop assign row[0] to url_array[1]? Doesn’t the array start with 0? Why does this loop keep assigning row[0] to the url_array array? ? Reply to discussion (solution) Why should I write this, the author must have his reasons It does not loop forever. It ends when $result->fetch_row() returns false When reading other people’s code, you must first understand what they are doing. Then comes the specific approach Why is it written like this? The author must have his reasons It is not a loop all the time. When $result-> It ends when fetch_row() returns false When reading other people’s code, you must first understand what he is doing. Then comes the specific approach Hello, fetch_row() returns an array. Does index 0 of this array represent a row? If there are multiple rows, is the array re-indexed or does it start at 0? fetch_row returns a one-dimensional array, and index 0 represents the first element fetch_row returns a…

PHP basic question, session variable array, please give me some advice

if($new) { //new item selected if(!isset($_SESSION[‘cart’])) { $_SESSION[‘cart’] = array() ; // $_SESSION[‘items’] = 0; $_SESSION[‘total_price’] =’0.00′; } if(isset($_SESSION[‘cart’][$new])) //What does this sentence mean? ? ? $new is an incoming parameter, which is the isbm code of a book, 9787111262817. What does $_SESSION[‘cart’][$new] mean? ? What will be the result? Can you describe it in detail. Thanks ing…. $_SESSION[‘cart’][$new]++; else $_SESSION[‘cart’][$new] = 1; Reply to discussion (solution) ??Can you understand?? $new=’a’; $_SESSION [‘cart’]=array( ‘a’=>’xxx’, );

php calls webservices error, please give me some advice

soap_defencoding = ‘UTF-8′ ;$params = array(’11’);echo $soap->call(‘test’,$params);?> Fatal error: Uncaught SoapFault exception: [Client] SoapClient::SoapClient () [soapclient.soapclient]: Invalid parameters in /opt/lampp/htdocs/shopping2013/Dragon/Client.php:12 Stack trace: #0 /opt/lampp/htdocs/shopping2013/Dragon/Client.php(12): SoapClient->SoapClient(‘http://192.168….’, true) #1 {main} thrown in /opt/lampp/htdocs/shopping2013/Dragon/Client.php on line 12 What is this Error, how to deal with it Reply to discussion (solution) soapclient is a class extended by php SOAP nusoap.php defines soap_client, right? soapclient is a class extended by php SOAP nusoap.php defines soap_client, right? Two classes are defined class nusoap_base class nusoap_client extends nusoap_base No, there are several classes class nusoap_base class nusoap_fault extends nusoap_base class nusoap_xmlschema extends nusoap_base class soapval extends nusoap_base class soap_transport_http extends nusoap_base class nusoap_server extends nusoap_base class wsdl extends nusoap_base class nusoap_parser extends nusoap_base class nusoap_client extends nusoap_base The soap call passed. There is a problem with your client.php itself. Open this CLIENT separately. php, see if there is any problem The soap call passed. There is a problem with your client.php itself. Open this CLIENT separately. php, see if there is any problem The error posted in the question is an error in accessing client.php client.php is an error in your internal project, which has nothing to do with WEBSERVICE What happened Dear, has the problem been…

PHP gets value from database, please give me some advice

The database name of the employee management system I made: empsys, which contains two tables: emp and admin The existing code is as follows: Please tell me where I’m going wrong! Why can’t I get the value? Reply to discussion (solution) Change mysql_fetch_row to mysql_fetch_assoc or mysql_fetch_array If you want to use the database ID mode to apply mysql_fetch_assoc, change the while loop. If you want to use mysql_fetch_row Then? The following $row[‘id’], $row[‘name’], $row[‘grade ‘] Want to change? $row[0], $row[1], $row[2] can be modified accordingly. Thank you everyone, I have done it according to your tips, thank you very much

I am confused while learning php, please give me some advice

class Test1 { static private $_instance; //static private private public $_obj; //private static public function getInstance($_obj) { self::$_instance = new self (); self::$_instance->_obj = $_obj; self::$_instance->_obj->run(); }}class Test2 { public function run() { echo 123; }}Test1::getInstance( new Test2()); //Why is there no output of 123? Reply to discussion (solution) private public $_obj; Change to private or public, only one modifier can be used private public $_obj; //Private Error report Fatal error: Multiple access type modifiers are not allowed in Fatal error: Multiple access type modifiers are not allowed in As long as you do not block the error checking level, PHP will tell How can you have any problemsDon’t cause trouble for yourself

The problem of passing two form values ​​in PHP, please give me some advice

I wrote two forms on one page Upload pictures: The file types allowed to be uploaded are: After uploading the file, I want to fill in other data in another form and write it into the database, but I just can’t get the name of the image uploaded in the first form. What should I do? Reply to discussion (solution) Consider writing a form Uploaded The file name is in $_FILES, not $_POST Consider writing it in a form Writing it in a form My image preview is gone. Can I still get the uploaded value? The uploaded file name is in $_FILES, not $_POST Medium My value is correct, but I cannot get the file name when submitting the second form, because my first form is specifically for uploading images There is no file name in the second form, so of course it cannot be retrieved If it is done twice, it needs to be cached on the server /p> There is no file name in the second form, so of course it cannot be retrieved If it is done in two times, it needs to be cached on the server side Product name if(isset($_POST[product]) ){ $db->query(“INSERT INTO `p_product`…

PHP string replacement problem, I found that it cannot be achieved no matter what, please give me some advice

There is such a requirement: there is a string ‘abc’, and I want to replace the ‘a’ in it with ‘ab’, and the ‘b’ in it with ‘cd’, that is, I finally get ‘abcdc’. I found that it couldn’t be achieved, such as using ‘str_replace’ <?php$str = 'abc';var_dump(str_replace( ['a', 'b'], ['ab', 'cd'], $str)); The returned result is ‘acdcdc’. The process of ‘str_replace’ seems to be to first replace ‘a’ with ‘ab’ to get ‘abbc’, and then replace ‘b’ in ‘abbc’ with ‘cd’ to get ‘acdcdc’, that is, the whole process is: ‘abc ‘ -> ‘abbc’ -> ‘acdcdc’. ‘preg_replace’ is the same process. How to implement ‘abc’ -> ‘abcdc’? ? ? Waiting for the experts, thank you very much Reply to the discussion (solution) No Hanging on a tree, PHP has provided various processing methods $str = ‘abc’;echo strtr($str, array(‘a’ => ‘ab ‘, ‘b’ => ‘cd’)); abcdc Don’t hang yourself from a tree, PHP has provided various processing methods $str = ‘abc’;echo strtr($str, array(‘a’ => ‘ab’, ‘b’ => ‘cd’)); abcdc Look, what am I talking about? Just come to CSDN and ask. Thank you very much

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索