GithubHelp home page GithubHelp logo

Comments (1)

cristopher avatar cristopher commented on July 24, 2024

This foreach only used if you need send information or data to the view

if you need send data to the view use:

$this->View->render('note/index', $data)

if you no need send info to the view use:

$this->View->render('note/index')

'note/index' is a file in view folder
$data is index array

$data = ["pizza" => true, "ingredients" = "cheese, tomato"];

foreach only run if $data != null
application/core/view.php

foreach ($data as $key => $value) {
$this->{$key} = $value;
}

for each add you data array in element $this of Class View


Ej:

in controller/NoteController.php create new function:

public function hello(){
        $this->View->render('note/hello', array(
            'title' => 'Hello men')
        );
}

in folder view/note create new file "hello.php"

put in this file "Hello.php"

<p><?= $this->title; ?></p>

open you browser and go to http://localhost/note/hello
you see "Hello men"

in this array you send anything string number array or object, and you use in view
$this->anything

from huge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.