Brother, I am new to php. I don’t understand this program. Please explain.

I am new to php and I don’t understand this program. Please explain ​ <?php function dealdata(&$value,&$key) { $value.=”123″; $key.=”456″; $cnt++; } $cnt = 0; $states = array(“a”=>”aa”,”b”=>”bb”,”c”=>”cc”); echo $cnt.”“; print_r($states); array_walk($states,”dealdata”); echo $cnt.”“; print_r($states); ?> Question 1: I think $cnt is global, so I think cnt should be 3 (I studied C++ before) Question 2: The value of $states has changed, why hasn’t the key changed? I obviously changed the key and value? Please give me some advice, the more detailed the better——Solution——————–Question 1 Yes, $cnt is global, but if you change its value inside the function, it is only valid inside the function and invalid outside the function. Question 2 You can only modify its value through array_walk, please read the manual. ——Solution——————–Question 1: I think $cnt is global, so I think cnt should be 3 (I studied C++ before) Unlike C++, PHP masks all external variables in functions If external variables are used in a function, a global declaration is required Question 2: The value of $states has changed, why hasn’t the key changed? I obviously changed the key and value? Changing the host’s structure is not allowed in array_walk Changing the key means changing the structure,…

Brother, why am I obsessed with PHP?

Why am I obsessed with PHP I have been working with PHP for more than a year. Now I am also engaged in web development related work. The main implementation is PHP+MySQL, so I basically use PHP every day. The more you know about PHP, the deeper you will discover Now I am becoming more and more obsessed with PHP. why not? PHP has grown from being able to simply process forms to today’s preferred server-side processing language for web development. Along the way, PHP developers and maintainers have continued to improve it. PHP is committed to reducing the learning costs of web developers and improving the operating efficiency of web programs. It is obvious that they have done it. For such a scripting language that is dedicated to Web programmers, how can I not love her! ? Now that I think about it, my exposure to PHP was a complete coincidence. In college, I majored in Mechanism, whose full name is “Mechanical Design, Manufacturing and Automation Major.” This major and computer programming are completely different worlds. If If I have to make some connections, the only ones I can think of are a control program for controlling the tool…

Brother, I wrote the php class. If you need the core class, please reply (b-)b

php Write your review! Come on, watch it all Member login | User registration Recommended reading php Notes on how to write mysql insert (reprinted) The general requirement for making an interface today is to obtain data from system A to system B. I am not familiar with system A. This system was purchased and there is no need to modify it. There is no problem in daily use identity_insert… [detailed] Crayon Shin-chan 2023-09-17 16:49:20 php public function list() reports error This is a function in PHP that is used to assign values ​​to a set of variables in one operation. Used to traverse arrays, such as: list(a,b,$c)array(3,7,9);list& … [detailed] Crayon Shin-chan 2023-09-17 16:49:18

Brother, I want to display the php file code on the web page, how to do it safely?

I want to display the php file code in the web page, how to do it safelyThis post was last edited by taodala on 2012-11-08 21:58:29 I have a website, and I want to create a function, which is to browse php files uploaded by netizens online. My current idea is to filter out <?php so that php files cannot be executed. Is this safe? Why,——The best solution——————–How can I automatically post my last post? Out I would say that as long as you don’t use eval, just output directly What needs to be guarded against is XSS attacks. The simplest way is to use htmlspecialchars to filter all entities into entity characters——Other solutions———– ———It is risky to filter only these two impressions. It is best to filter them all, which is safe—- –Other solutions——————–This post was last edited by xuzuning on 2012-11-09 22:22:29 highlight_file highlight_string Both safe and beautiful——Other solutions——————–As long as you don’t eval——Other solutions——————– Quote: Why did my last post get automatically posted I would say that as long as you don’t use eval, just output directly What needs to be guarded against is XSS attacks. The simplest way is to use htmlspecialchars to filter all entities…

Brother, my phpmyadmin works normally, but why does it prompt an error when I use mysql_connent()?

My phpmyadmin works normally, but why does it prompt an error when I use mysql_connent()? I configured php and mysql, and I can access and modify the database normally from phpmyadmin. However, for some reason, when accessing from a function I wrote, I always get the prompt “undefined function” <?php $host = “localhost”; $username = “root”; $passowrd=”123456″; $dbname=”test”; $res = mysql_connent($host,$username,$password) or die(mysql_error()); @mysql_select_db($dbname); ?> How to solve this? ——The best solution——————–mysql_connent -> mysql_connect

Brother, I have a problem with session when using ThinkPHP.

I have a session problem when using ThinkPHP. Why is the value set using the session function or _SESSION only available in the current method, but the value is empty when it is changed to another method? For example class UserAction extends Action { function login() { session(‘name’,’admin’); echo session(‘name’); //Admin can be displayed here } function rendersession() { echo session(‘name’);////It will be empty when accessing this method. } The same is true when using TP’s verification code function. The accessed session(‘verify’) value is empty. ——The best solution——————–Partial Scope, if it is global, use GLOBAL——Other solutions——————– Quote: Local scope, if it is global, use GLOBAL Then the author should take a look for himself——Other solutions——————–I’ll give it my own thumbs up and ask for answers……——Other solutions————- ——-I don’t quite understand what LS means. I’m new to PHP, can you be more specific? ——Other solutions——————–is PHP settings issue. Just set session.save_path in php.ini.

Brother, I used flex+php+mysql to read data and it showed that there were related problems! How to change the writing method?

I used flex+php+mysql to read data and there was a problem! How can I change the writing? ? This is the code for BookDAO.php: <?php $link = mysql_connect(“localhost”,”***”,”***”); Mysql_select_db(“book”); mysql_query(“SET NAMES ‘utf8’ “); /*Return books in XML format*/ $sql = ‘SELECT * FROM books’; $result = mysql_query($sql); echo “”; echo “\n”; while($row = mysql_fetch_array($result)){ echo “” .$row[“id”].””; echo “” .$row[“author”]. “”; echo “\n”; echo “” .$row[“genre”]. “\n”; echo “” .$row[“price”]. “\n”; echo “” .$row[“publish_date”]. “\n”; echo “” .$row[“description”]. “\n”; } echo “\n”; Mysql_close($link); ?> The result displayed in mxml is: Since I can’t put a picture, I simply counted the results: Hello! This is the content of the data displayed by the datagrid. The auhtor tag is also displayed on the page, instead of just displaying the content “Hello!” . . . Looking for a way to write it? ——The best solution——————–htmlspecialchars ()Put your XML string in and then print it out. This is because you did not specify the content-type with Header. You can directly header(“Content-Type:xml”);, the code behind remains unchanged, and the browser can still print out tagged XML. ——Other solutions——————–Change it Header: header(“Content-Type:xml”);——Other solutions—————- —-How to change it? I have never used this before. I don’t know…

Brother, I will add the function of online chat between visitors and posters to phpwind.

Brother, I will add the function of online chat between visitors and posters to phpwind.

I added the function of online chat between visitors and posters to phpwind When I was using the phpwind forum, I found that the visitors and Bamboo or Communication between posters is very troublesome, so I added him among visitors or friends Online peer-to-peer chat function, the effect is as follows: In fact, speaking of It’s also very simple. Just add a few lines of code to the read.php file and you’re done. This is what I Forum effect: http://bbs.faqee.com This is the post description: http://bbs.faqee.com/read.php?tid=20 If you are interested, I can Write about his embedding method! You can add this feature by following the steps below: Switch to the template\wind directory, open header.html, and add under the sentence: Open the footer.html file and append this sentence at the end of the file:> Okay, open read.html, search for the word “Top”, and after adding it, it will look like this: Top(Chat) Please note that the 3 sentences in bold are added content. If you don’t understand, you can leave a comment!

Brother, I am a PHP programmer. Brother, I speak for myself.

I am a PHP programmer, I speak for myself You only see my ability but not Didn’t see my efforts You have your rules but I have no choice You deny my present and I will decide my future You laugh at me for having nothing and not being worthy of love I will persist silently and wait for true love. You can ignore our existence I use programs to prove whose era this is Coding is a lonely journey, and bugs and changes are inevitable along the way. But so what, even if you can’t execute it, you still have to make it beautifully! I am a programmer and I speak for myself. 1Fno_move_this_year08:31 yesterday Restore original

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

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
首页
微信
电话
搜索