MVC dirname (--file--)

Source: Internet
Author: User

1, the full name of MVC is the model View Controller, is the models-view (Controller) abbreviation, a software design paradigm, with a business logic, data, interface display separation method to organize the code, Aggregating business logic into a single component does not require rewriting business logic while improving and personalizing the interface and user interaction. MVC is uniquely developed to map the traditional input, processing, and output functions in a logical graphical user interface structure.

    • Model (models) represent the core of the application (such as a list of database records).
    • View displays data (database records).
    • The controller (Director) processes the input (writes to the database record).
The MVC pattern also provides complete control over HTML, CSS, and JavaScript. Model is the part of your application that handles application data logic.
Typically, model objects are responsible for accessing data in the database. View is the part of the application that handles the display of data.
Typically views are created from model data. A controller is a part of an application that handles user interaction.
Usually the controller is responsible for reading data from the view, controlling user input, and sending data to the model. A view view is an interface that the user sees and interacts with. For older Web applications, views are an interface of HTML elements, and in modern Web applications, HTML still plays an important role in the view, but new technologies are emerging, including Adobe Flash and like xhtml,xml/xsl, Some identity languages and Web services, such as WML. The benefit of MVC is that it can handle many different views of the application. There is really no real processing happening in the view, whether the data is stored online or an employee list, as a view, it is simply a way to output data and allow the user to manipulate it. Model models represent enterprise data and business rules. Of the three parts of MVC, the model has the most processing tasks. For example, it may use a Component object such as EJBS and ColdFusion to process the database, the data returned by the model is neutral, that is, the model is independent of the data format, so that a model can provide data for multiple views, Because the code applied to the model can be reused by multiple views only once, it reduces the repetition of the code. The controller controller accepts the user's input and invokes the model and view to complete the user's needs, so when you click a hyperlink in a Web page and send an HTML form, the controller itself does not export anything and do any processing. It simply receives the request and decides which model component is called to process the request, and then determines which view to use to display the returned data. 2.

DirName () function

String DirName (String $path)

Gives a string containing a full path to a file, which returns the directory name after removing the file name.

In Windows, slashes (/) and backslashes () can be used as directory separators. In other environments it is a slash (/).

Example

The code is as follows Copy Code

Echo dirname ("c:/testweb/home.php");
Echo dirname ("/testweb/home.php");
?>

Output:

C:/testweb
/testweb

__file__

The full path and file name of the file. If used in included files, returns the included file name

DirName (__file__)
__FILE__: called the PHP Magic Constant, returns the full path and file name of the currently executing PHP script, containing an absolute path
1) the dirname (__file__) function returns the path where the script is located. Update Network
For example, the file b.php contains the following

The code is as follows Copy Code

$basedir = DirName (__file__);
Echo $basedir
An absolute path to the file will be printed on the page!
?>

DirName (__file__) typically returns a directory structure of the current directory of the file to the system root directory.

The current file name is not returned.

DirName (__file__) may also return one. (current directory)
[The reason is that the b.php file is under the default Web directory of the http.conf or PHP Configuration development environment.]
For example web_root: "c:/root/www/".

The b.php file path is: "c:/root/www/b.php". Using the method tip, if you repeat one at a time you can raise the directory up one level:
For example: $d = DirName (dirname (__file__));
The fact is that a directory to dirname () to do the parameters. Because DirName () returns the final directory without \ \ or
So when you reuse it, you can think of dirname () handling the lowest-level directory as a file name. Return as usual
The parent directory of the current directory. That way, you get the top level of the directory. Contains the file inclusion (DirName (__file__) that gets the top level of the directory. /.. /filename.php ')

MVC dirname (--file--)

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.