Home > Backend Development > PHP Tutorial > How to dump things in thinkphp model so that they can be displayed on the page?

How to dump things in thinkphp model so that they can be displayed on the page?

WBOY
Release: 2016-10-17 09:30:17
Original
1580 people have browsed it

My table is news, and I wrote the model. Now I have a problem in the model. I don’t know if a variable has a value. I found that I can’t just dump the variable directly on any page, such as the view page, like a controller. The value of this variable can be displayed on the view page

On the model page, if I write any public function, I can’t dump it if I write something in it. I want to see the variables printed in my model on the news list page or the view page. What should I do? How do I debug this?

Asking for help from an expert, thank you

How to dump things in thinkphp model so that they can be displayed on the page?

Reply content:

My table is news, and I wrote the model. Now I have a problem in the model. I don’t know if a variable has a value. I found that I can’t just dump the variable directly on any page, such as the view page, like a controller. The value of this variable can be displayed on the view page

On the model page, if I write any public function, I can’t dump it if I write something in it. I want to see the variables printed in my model on the news list page or the view page. What should I do? How do I debug this?

Asking for help from an expert, thank you

How to dump things in thinkphp model so that they can be displayed on the page?

Call the method in the model you wrote in the controller of your news page, and you can see the dump data in the model

The reason why the dump cannot come out is probably because that piece of code has not been executed.

If you pass data to view

<code>$this->assign('data',$data);</code>
Copy after login

You can also insert it in the html page of the view

<code><?php 
    dump($data);
?></code>
Copy after login

In the model, the dump can be displayed directly on the page. If it is not displayed, there is something wrong with the code. Post the controller code and take a look.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template