How the ZF framework assigns an array of PHP pages to a variable in the template page JS

Source: Internet
Author: User
How does the ZF framework assign an array of PHP pages to a variable in the template page js?
Assign variables on the Controller page:
$this->view->request = $request; $request is an array

Now want to in the template page JS to assign this $request to a JS variable, how to implement?

------Solution--------------------
Get a hidden,value={$Js _request} in the template page
Assign values to variables in the controller: Assgin ("Js_request", $request);
Js to take this hidden value: Var js_request=id_hidden.value;
------Solution--------------------
Json_encode?
------Solution--------------------
Json_encode is it possible to turn PHP data into JS data?
------Solution--------------------
You can parse the array into a string or JSON, the front-end JS can be converted to the group again.

But JSON data is better, JS can be used directly.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.