Php Basics ~

Source: Internet
Author: User
Tags php basics
Php Basics ~~~~ The function & nbsp; view ($ view & nbsp; false) & nbsp ;{! & Nbsp; $ view & nbsp; & amp; & nbsp; $ view & nbsp; php Basics. please refer ~~~~ ,

This post was last edited by wkhegx at 22:18:50 on

function view($view = false) {
! $view && $view = $this->controller . '/' . $this->action;
include ROOT . 'view/' . $view . '.php';
}


What does $ view = $ this-> controller. '/'. $ this-> action? Adding/in the middle, division?

Define ('root', dirname (_ FILE __). '/.. /'); this _ FILE _ gets the current FILE directory, but. "/... /"What does it mean ??



------ Solution --------------------
What does $ view = $ this-> controller. '/'. $ this-> action? Adding/in the middle, division?
The operator is not the operator, but a string.
$ View = $ this-> controller. '/'. $ this-> action; concatenates $ this-> controller,/, $ this-> action, and then returns the value to $ view.
For example
$ This-> controll = 'web'
$ This-> action = 'index'

So $ view = 'web/index ';

Define ('root', dirname (_ FILE __). '/.. /'); this _ FILE _ gets the current FILE directory, but. "/... /"What does it mean ??
../Indicates the parent category
For example, the project structure is as follows:
Web/a/B/c/d. php
Then, in d. php, dirname (_ FILE _). '/../' is equivalent to web/a/B/
------ Solution --------------------
Path. Equivalent \
In php, "/" is the path character and "\" is the escape character.
------ Solution --------------------
Echo $ view;
Echo dirname (_ FILE __).'/../';

Don't you know?
Don't say you don't have a php environment

Related Article

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.