Home  >  Article  >  Backend Development  >  Sharing of key PHP interview questions (1)

Sharing of key PHP interview questions (1)

小云云
小云云Original
2018-03-22 13:38:491697browse

This article mainly shares with you some interview questions about PHP. These PHP interview questions are some key questions. I hope they can help you.

1. One of the major advantages of PHP language is cross-platform. What is cross-platform?

The optimal combination of PHP's running environment is Apache+MySQL+PHP. This running environment can be configured on different operating systems (such as windows, Linux, etc.) and is not restricted by the operating system, so it is called Cross-platform

2. How many methods are there for data submission in WEB development? What's the difference? Which method does Baidu use?

Get and post two methods

The difference: 1. Get obtains data from the server, post transmits data to the server

2. The value passed by Get is visible in the url, and post Invisible in the url

4. The value passed by Get is generally within 2KB, and the size of the value passed by post can be set in php.ini

5. The security of get is not low, but the security of post Higher, but the execution efficiency is higher than Post

Suggestions:

1. The get type is less secure than the Post type. It contains confidential information. It is recommended to use the Post data submission type;

2. It is recommended to use the Get method for data query; it is recommended to use the Post method for adding, modifying or deleting data;

The get method used by Baidu, because it can be seen from its URL

3. Understand which frameworks, template engines, systems, etc. of PHP

Frameworks: There are many frameworks, such as zendframe, CI, Yii, etc. What we have learned is thinkphp

Template engines: There are also There are many in the textbooks. What we have learned is the smart

system: there are many, such as Kangsheng's products (uchome, supesite, discuzX, etc.), Empire system, DEDE (Dream Weaver), ecshop, etc. , what we have learned is DEDECMS, Ecshop

4. What are the web front-end technologies you have mastered?

Proficient in p+CSS web page layout, JavaScript, jQuery framework, photoshop image processing

5. What are the advantages of AJAX?

ajax is an asynchronous transmission technology that can be implemented through javascript or the JQuery framework to achieve partial refresh, which reduces the pressure on the server and improves the user experience

6. Safe to one It is very important for a set of programs. Please tell me what safety mechanisms should be paid attention to during development?

① Prevent remote submission; ② Prevent SQL injection and filter special codes; ③ Prevent registration machine flooding and use verification codes;

7. In the development of the program, how to improve the performance of the program operating efficiency?

① Optimize SQL statements, try not to use select * in query statements, use which field to check which field; use less subqueries instead of table connections; use less fuzzy queries; ② Create indexes in data tables; ③ Right The data frequently used in the program is cached;

8. Can PHP be used with other databases?

PHP is the best combination with MYSQL database. Of course, PHP can also be used with other databases, such as MSSQL, etc. PHP has reserved functions for operating MSSQL, which can be used as long as it is turned on

9. Nowadays, MVC three-layer structure is often adopted in programming. Which three layers does MVC refer to and what are its advantages?

The three layers of MVC refer to: business model, view, and controller. The controller layer calls the model to process the data, and then maps the data to the view layer for display. The advantages are: ① It can achieve code reusability, Avoid code redundancy; ②M and V implement code separation, so that the same program can use different expressions

10. Understanding of json data format?

JSON (JavaScript Object Notation) is a lightweight data exchange format. The json data format is fixed and can be used for data transmission in multiple languages.

Processing json format in PHP The function is json_decode(string $json [, bool $assoc]), which accepts a JSON format string and converts it into a PHP variable. The parameter json is the json string format string to be decoded. assoc When this parameter is TRUE, it will return array instead of object;

Json_encode: Convert PHP variables into json format

14. What are the common functions for PHP to process arrays? (Focus on the 'parameters' and 'return value' of the function)

①array() creates an array; ②count() returns the number of elements in the array; ③array_push() inserts one or more elements into the end of the array ( Push onto the stack); ④array_column() returns the value of a single column in the input array; ⑤array_combine() creates a new array by merging two arrays; ⑥array_reverse() returns the array in reverse order; ⑦array_unique() removes duplicates in the array Value; ⑧in_array() checks whether the specified value exists in the array;

15. What are the common functions for PHP to process strings? (Focus on the ‘parameters’ and ‘return value’ of the function)

①trim() removes blank characters and other characters on both sides of the string; ②substr_replace() replaces part of the string with another string; ③substr_count() counts the number of times a substring appears in the string; ④substr( ) returns a part of the string; ⑤strtolower() converts the string to lowercase letters; ⑥strtoupper() converts the string to uppercase letters; ⑦strtr() converts specific characters in the string; ⑧strrchr() finds the string in another character The last occurrence in a string; ⑨ strstr() finds the first occurrence of a string in another string (case-sensitive); strrev() reverses the string; strlen() returns the length of the string; str_replace() Replace some characters in the string (case-sensitive); print() outputs one or more strings; explode() breaks the string into an array; is_string() detects whether the variable is a string; strip_tags() starts from Remove HTML tags from a string; mb_substr() is used to intercept Chinese and English functions

16. What are the commonly used functions for PHP processing time? (Focus on the ‘parameters’ and ‘return value’ of the function)

date_default_timezone_get() returns the default time zone.

date_default_timezone_set() sets the default time zone.

date() formats local time/date.

getdate() returns date/time information.

gettimeofday() returns the current time information.

microtime() returns the number of microseconds in the current time.

mktime() returns the Unix timestamp of a date.

strtotime() parses any English text date or time description into a Unix timestamp.

time() returns the Unix timestamp of the current time.

17. Common functions used in PHP to process databases? (Focus on the 'parameters' and 'return value' of the function)

Please refer to the PHP manual and read it carefully. This item is very important.

18. What are the commonly used functions of PHP to operate files? (Focus on the 'parameters' and 'return value' of the function)

①Open the file; ②Delete the file; ③Read the file; ④Write the file; ⑤Modify the file; ⑥Close the file; ⑦Create file, etc. etc. This item is very important. It is often used to generate cache or static files at work. Please refer to the PHP manual and carefully review

19. What are the common functions of PHP operating directories (folders)? (Focus on the 'parameters' and 'return value' of the function)

①Open the directory; ②Delete the directory; ③Read the directory; ④Create the directory; ⑤Modify the directory; ⑥Close the directory, etc. This item is very Important, in your work, you often create or delete directories for uploaded files, and create or delete directories for cached and static pages. Please refer to the PHP manual and read carefully

3. Object-oriented part

1. What is object-oriented? (Answer with understanding)

Answer: Object-oriented OO = object-oriented analysis OOA + object-oriented design OOD + object-oriented programming OOP; the popular explanation is "everything is an object" ", treat all things as independent objects (units) that can complete their own functions, instead of being divided into functions like C.

The current pure OO languages ​​are mainly Java and C#. PHP and C++ also support OO. C is process-oriented.​​

2. Briefly describe the access rights of private, protected, and public modifiers.

Answer: private: Private members can only be accessed inside the class.

protected: Protected members, accessible within the class and inherited classes.

public: Public members, completely public, no access restrictions.

3. What is the difference between heap and stack?

Answer: The stack is a memory space allocated during compilation, so the size of the stack must be clearly defined in your code;

The heap is a memory space dynamically allocated during program running. , you can determine the size of heap memory to be allocated based on the running conditions of the program.

4. The main difference between XML and HTML

Answer: (1) XML distinguishes between uppercase and lowercase letters, while HTML does not.

(2) In HTML, you can omit closing tags such as

or if the context clearly shows where the paragraph or list key ends. In XML, the closing tag must not be omitted.

(3) In XML, elements that have a single tag without a matching closing tag must end with a / character. This way the parser knows not to look for the closing tag.

(4) In XML, attribute values ​​must be enclosed in quotation marks. In HTML, quotation marks are optional.

(5) In HTML, you can have attribute names without values. In XML, all attributes must have corresponding values.

5. What are the characteristics of object-oriented?

Answer: Mainly include encapsulation, inheritance, and polymorphism. If it is 4 aspects, add: abstraction.

The following explanation is for understanding:

Encapsulation:

Encapsulation is the basis for ensuring that software components have excellent modularity. The goal of encapsulation is to achieve high content of software components. Aggregation, low coupling, preventing the impact of changes caused by program interdependence.

Inheritance:

When defining and implementing a class, you can do it on the basis of an existing class. You can use the content defined by this existing class as your own content, and you can add some new content or modify it. The original method is made more suitable for special needs, which is inheritance. Inheritance is a mechanism for subclasses to automatically share parent class data and methods. This is a relationship between classes that improves the reusability and scalability of software.

Polymorphism:

Polymorphism means that the specific type pointed to by the reference variable defined in the program and the method call issued through the reference variable are not determined during programming, but in the program It is determined during running time that a reference variable will point to an instance object of which class. The method call issued by the reference variable is a method implemented in which class. This must be determined during the running of the program.

Abstract:

Abstraction is to find out the similarities and commonalities of some things, and then classify these things into a class. This class only considers the similarities and commonalities of these things, and Will ignore those aspects that are irrelevant to the current topic and goal, and focus on aspects that are relevant to the current goal. For example, if you see an ant and an elephant and you can imagine how they are similar, that is abstraction.

6. What are the concepts and differences between abstract classes and interfaces?

Answer: Abstract class: It is a special class that cannot be instantiated and can only be used as a parent class of other classes. Declared using the abstract keyword.

It is a special abstract class and a special class that uses interface declaration.

(1) The operations of abstract classes are implemented through the inheritance keyword extends, and the use of interfaces is implemented through the implements keyword.

(2) There are data members in the abstract class, which can realize data encapsulation, but the interface has no data members.

(3) Abstract classes can have constructors, but interfaces have no constructors.

(4) Methods of abstract classes can be modified with private, protected, and public keywords (abstract methods cannot be private), while methods in interfaces can only be modified with public keywords.

(5) A class can only inherit from one abstract class, and a class can implement multiple interfaces at the same time.

(6) An abstract class can have implementation code for member methods, but an interface cannot have implementation code for member methods.

7. What is a constructor, what is a destructor, and what is its function?

Answer: The constructor (method) is the first method automatically called by the object after the object is created. It exists in every declared class and is a special member method. Its function is to perform some initialization tasks. In Php, __construct() is used to declare the constructor method, and only one can be declared.

The destructor (method) has the opposite effect to the constructor. It is the last method automatically called by the object before it is destroyed. It is a newly added content in PHP5 that is used to perform some specific operations before destroying an object, such as closing files and releasing memory.

8. How to overload the method of the parent class, give an example

Answer: Overloading means overriding the method of the parent class, that is, using the method in the subclass Replacing a method inherited from the parent class is also called method overriding.

The key to overriding the parent class method is to create the same method in the parent class in the subclass, including the method name, parameters and return value type. In PHP, it is only required that the names of the methods are the same.

9. What are the commonly used magic methods? Example

Answer: PHP stipulates that methods starting with two underscores (__) are reserved as magic methods, so it is recommended that your function name should not start with __ unless it is to overload an existing magic method. .

__construct() is automatically called when instantiating a class.

__destruct() is automatically called when the class object is used.

__set() is called when assigning a value to an undefined property.

__get() is called when undefined attributes are called.

__isset() Will be called when using isset() or empty() function.

__unset() Will be called when using unset().

__sleep() is called when serializing using serialize.

__wakeup() is called when deserializing using unserialize.

__call() is called when calling a method that does not exist.

__callStatic() calls a static method that does not exist.

__toString() is called when converting an object into a string. Such as echo.

__invoke() Called when trying to invoke an object as a method.

__set_state() Called when using the var_export() function. Accepts an array parameter.

__clone() is called when using clone to copy an object.

10. What do the three keywords $this, self, and parent represent respectively? In what situations is it used?

Answer: $this current object

self current class

parent parent class of the current class

$this is used in the current class, use -> ;Call properties and methods.

self is also used in the current class, but it needs to be called using ::.

parent is used in the class.

11. How to define constants in a class, how to call constants in a class, and how to call constants outside a class.

Answer: The constants in the class are also member constants. A constant is a quantity that does not change and is a constant value.

Define constants using the keyword const.

For example: const PI = 3.1415326;

Whether it is within a class or outside a class, the access of constants is different from that of variables. Constants do not need to instantiate objects.

Access to constants The format is the class name plus the scope operation symbol (double colon) to call.

That is: class name :: class constant name;

12. How to use scope operator::? In what situations is it used?

Answer: Calling class constants

Calling static methods

13. What is the working principle of the __autoload() method?

Answer: The basic condition for using this magic function is that the file name of the class file must be consistent with the name of the class.

When the program is executed to instantiate a certain class, if the class file is not introduced before instantiation, the __autoload() function will be automatically executed.

This function will search for the path of the class file based on the name of the instantiated class. When it is determined that the class file does exist in the path of the class file,

execute include or require to load it. Enter this class, and then the program continues to execute. If the file does not exist in this path, an error will be prompted.

Using the automatically loaded magic function eliminates the need to write many include or require functions.

4. ThinkPHP part

1. Common PHP framework

Answer: thinkPHP

yii

ZendFramework

CakePhp

sy

2. How to understand the single entry file in TP?

Answer: ThinkPHP uses a single entrance mode for project deployment and access. No matter what function is completed, a project has a unified (but not necessarily the only) entrance. It should be said that all projects start from the entry file, and the entry files of all projects are similar. The entry file mainly includes:

Define the framework path, project path and project name (optional)

Define related constants for debugging mode and running mode (optional)

Load the framework entry file (required)

3. MVC in ThinkPHP What is stratification? (Understanding)

Answer: MVC is a method of separating the logical layer and presentation layer of an application. ThinkPHP is also based on the MVC design pattern. MVC is just an abstract concept and has no particularly clear regulations. The MVC layering in ThinkPHP is roughly reflected in:

Model (M): The definition of the model is completed by the Model class.

Controller (C): Application controller (core controller App class) and Action controller both assume the role of controller. Action controller completes business process control, while application controller is responsible for scheduling control.

View (V): It consists of View class and template file. The template is 100% separated and can be previewed and produced independently.

But in fact, ThinkPHP does not rely on M or V, which means it can work without a model or view. It doesn’t even rely on C. This is because ThinkPHP also has a master controller on top of Action, the App controller, which is responsible for the overall scheduling of the application. In the absence of C, view V must exist, otherwise it is no longer a complete application.

In short, ThinkPHP's MVC model only provides a means of agile development, rather than sticking to MVC itself.

5. How to understand the behavior in ThinkPHP 3.0 architecture three (core + behavior + driver)?

Answer: Core + Behavior + Driver

The official abbreviation of TP is: CBD

Core: It is the core code of the framework, an indispensable thing, TP itself is A framework developed based on MVC ideas.

Behavior: Behavior plays a decisive role in the architecture of the new version of ThinkPHP. On the core of the system, many tag extension bits are set, and each tag position can execute its own independent behavior in turn. This is how behavioral extensions were born, and many system functions are also completed through built-in behavioral extensions. All behavioral extensions are replaceable and additive, thus forming the basis for the assembly of the underlying framework.

Driver (Driver): database driver, cache driver, tag library driver and template engine driver, as well as external class extensions.

Frame, that is, framework. In fact, it is a semi-finished product of a certain application, a set of components for you to choose and use to complete your own system. To put it simply, you use the stage set up by others and you perform. Moreover, frameworks are generally mature, continuously upgraded software.

6. What is the conventional configuration?

Answer: Conventional configuration Previous page Next page Conventions are more important than configurations. This is an important idea that the system follows. The system has a built-in convention configuration file (Conf\convention.php located under the system directory). According to the general Most applications have default configurations for commonly used parameters. Therefore, for the configuration file of the application project, you often only need to configure different or new configuration parameters from the conventional configuration. If you completely adopt the default configuration, you do not even need to define any configuration file.

The conventional configuration file will be automatically loaded by the system and does not need to be loaded in the project.

7. What is SQL injection? (understand)

Answer: SQL injection attack is one of the common means used by hackers to attack the database. Some programmers do not judge the legality of user input data when writing code. The injector can enter a database query code in the form and submit it. The program will piece together the submitted information to generate a complete SQL statement, and the server will be deceived. Execute the malicious SQL command. The injector successfully obtains some sensitive data based on the results returned by the program, and even controls the entire server. This is SQL injection.

8. How does ThinkPHP prevent SQL injection? (Understanding)

Answer: (1) Try to use arrays for query conditions, which is a safer way;

(2) If you have to use string query conditions, use preprocessing Mechanism;

(3) Turn on data field type verification, and you can force conversion of numerical data types; (Field type verification has been mandatory since version 3.1)

(4) Use automatic verification and auto-complete mechanisms for custom filtering of applications;

(5) Use field type checking, automatic verification, and auto-complete mechanisms to avoid the input of malicious data.

9. How to enable debugging mode? What are the benefits of debug mode?

Answer: Turning on debugging mode is very simple. You only need to add a line of constant definition code to the entry file:

//Turn on debugging mode

define('APP_DEBUG', true);

//Load the framework entry file

require './ThinkPHP/ThinkPHP.php';

In After completing the development phase and deploying to the production environment, you only need to delete the debug mode definition code to switch to deployment mode. After turning on debugging mode, the system will first load the system default debugging configuration file, and then load the project's debugging configuration file. The advantages of debugging mode are:

Turn on logging, any error information and Debugging information will be recorded in detail to facilitate debugging;

Turn off the template cache, template modifications can take effect immediately;

Record SQL logs to facilitate SQL analysis;

Turn off field caching, data Table field modifications are not affected by caching;

Strictly checks file case (even on Windows platforms) to help you find Linux deployment problems in advance;

can be conveniently used at different stages of the development process, Including any required situations such as development, testing and demonstration, different application modes can configure independent project configuration files.

10. What configuration modes are supported in TP? priority?

Answer: ThinkPHP has created its own unique hierarchical configuration mode in project configuration. Its configuration level is reflected in:

Conventional configuration->Project configuration->Debug configuration-> ;Group configuration->Extended configuration->Dynamic configuration

The above is the loading order of configuration files, because the subsequent configuration will overwrite the previous configuration of the same name (without taking effect), so the priority is from Right to left.

11. What are the URL patterns in TP? Which is the default?

Answer: ThinkPHP supports four URL modes, which can be defined by setting the URL_MODEL parameter, including normal mode, PATHINFO, REWRITE and compatibility mode.

The default mode is: PATHINFO mode, set URL_MODEL to 1

12. What are the system variables in TP? How to get system variables?

Answer: How to obtain system variables:

You only need to call the following method in Action:

$this->Method name (" Variable name",["Filter method"],["Default value"])

13. What is the difference between D function and M function in ThinkPHP framework?

Answer: The M method instantiates the model without the user defining a model class for each data table. The D method can automatically detect the model class. If a custom model class exists, the custom model class will be instantiated. If not, the custom model class will be instantiated. exists, the M method will be automatically called to instantiate the Model base class. At the same time, models that have been instantiated will not be instantiated repeatedly (single case mode).

Back to top

5. smarty template engine

1. What is the difference between compilation and caching?

The compilation process of smarty is to take the template and replace the tags inside with the corresponding php code. This is the compilation of smarty. In fact, it is the process of mixing php and html

Smarty’s cache needs to be turned on manually. Smarty’s cache is to execute the compiled file and generate a static html page at the same time. When you access it again, you will access the html file. So in terms of efficiency, it is higher

2. What is smarty? What are the advantages of Smarty?

Smarty is a PHP template engine written in PHP , the purpose is to separate the PHP program from the artist, so that when the programmer changes the logical content of the program, it will not affect the artist's page design, and when the artist re-modifies the page, it will not affect the program logic of the program. This is important in multi-person cooperation. It is particularly important in the project. (It is also easy to develop multi-style programs)

Advantages of Smarty

1. Fast speed: compared with other template engines.

2. Compiled type: A program written in smarty must be compiled into a non-template technology PHP file at runtime

3 Caching technology: It can cache the HTML file that the user finally sees into a static HTML page

4. Plug-in technology: smarty can customize plug-ins.

Not suitable for using smarty

1. Content that needs to be updated in real time. For example, like stock display, it requires frequent data updates 2. Small projects. A small project that requires both an artist and a programmer because of its simplicity

3. Use {$smarty} in the template to retain variables

{$smarty.get.page} //Similar to accessing $_GET[page]

{ in a php script smarty.cookies.}

{smarty.post.}

{smarty.session.}

{smarty.server.}

4. Access variables in php in templates

There are two types of system constants and custom constants in php scripts. These two constants can also be accessed in Smarty templates and are not required Assigned from php, the value of the constant can be output directly as long as the variable is retained through {$smarty}. Example of outputting constants in a template:

{$smarty.const._MY_CONST_VAL}

{$smarty.const.__FILE__}

5. Variable modifier

{$var|modifier1|modifier2|.........}

<{$str} >

<{$str|capitalize}><{*First letter is capitalized*}>

<{$str|upper }><{*all uppercase*}>

<{$str|lower}><{*all lowercase*}>

<{$str|lower|upper}><{*all caps, adjusted from left to right*}>

<{$leg|truncate}> ;<{*String interception, default 80 characters*}>

<{$leg|truncate:10}><{*String interception, first 10 characters , including... three characters *}>

6. When php queries the mysql database, garbled characters appear when querying the Chinese results. How to deal with it? ? ? ?

1. File properties (save as)

2. File meta (when setting up browser parsing)

3. Encoding settings when connecting to the database

4. Use the header function in the PHP file to determine the encoding

7. Caching mechanism

If caching is turned on, smarty will generate a static html page at the same time. If it does not expire within the set time, when you visit again, the page you visited will be It is an html file, which reduces the need to read the database, so in terms of efficiency, it is higher.

8. Smarty’s assignment and loading template

$Smarty->assign(name,value)

$Smarty->display ('index.html')

9.What is the use of smarty template technology?

In order to separate php from html, artists and programmers should perform their own duties without interfering with each other.

10. What are the main configurations of smarty?

1. Introduce smarty.class.php;

2. Instantiate the smarty object;

3. Re-modify the default template path;

4 . Re-modify the path of the default compiled file;

5. Re-modify the path of the default configuration file;

6. Re-modify the path of the default cache.

7. You can set whether to enable cache.

8. You can set the left and right delimiters.

11. What details do you need to pay attention to when using smarty?

Smarty is a template engine based on the MVC concept. It divides a page program into two parts for implementation: the view layer and the control layer.

That is to say, smarty technology combines the user UI with Separate from php code.

In this way, programmers and artists perform their respective duties without interfering with each other.

12. Pay attention to the following issues when using smarty:

1. Configure smarty correctly. It is mainly necessary to instantiate the smarty object and configure the path of the smarty template file;

2. Use assign assignment and display display page in the php page;

3. No php code is allowed in the smarty template file Section, all comments, variables, and functions must be included in the delimiter.

A.{}

B. foreach

C. if else

D. include

E. Literal

Back to top

6. Secondary development system (DEDE, ecshop):

1. Understanding of secondary development

Secondary development, simply put It means customizing and modifying existing software, extending functions, and achieving the functions you want. Generally speaking, the core of the original system will not be changed.

2. MVC

Model (model) data processing.

View template display.

Controller controls the process.

What is the concept of MVC? What are the main tasks of each level?

MVC (Model-View-Controller) is a software design pattern or programming idea.

M refers to the Model model layer, V is the View layer (display layer or user interface), and C is the Controller layer.

The purpose of using mvc is to separate M and V, so that a program can easily use different user interfaces.

In website development,

The model layer is generally responsible for adding, deleting, modifying, and checking database table information.

The view layer is responsible for displaying page content.

The controller layer is responsible for M and V play a regulating role. The controller layer decides which method of which model class to call.

After the execution is completed, the controller layer decides which view layer to assign the result to.

3. Some warnings and errors appear when accessing the secondary development program after installation

Based on the errors, modify the server configuration parameters and Baidu

4 . Functions, replacement of templates, addition and modification of functions

In fact, it is object-oriented application, and replacement of templates is similar to the use of smarty

5. What secondary development things have been used? ?

Dedecms phpcms ecshop, basically if you have a good foundation, it will be no problem to learn.

6. Is it better to do primary development or secondary development like PHP?

Generally, small and medium-sized enterprises use cms system for secondary development, all for the sake of efficiency. Of course, if you want to develop it all at once, you can do it, as long as you know how to use the framework and have enough time. Large companies develop by teams to avoid copyright issues.

7. In the secondary development process, how are the method accesses between many classes transmitted?

It is not class inheritance but object combination. Pass the instantiated objects through global

8. If dedecms changes the directory, a certain item in the background cannot be entered. How to solve it?

Change the background core settings to the current project directory name

9. Do you understand the custom model in dedecms?

There is the concept of content model in the DreamWeaver system. Different content models can be used to build sites with different content forms. The system comes with the following models: ordinary articles, photo albums, software, and products. , classified information, special topics. Through the system's own model, we can use it to build different types of sites. For example, you can use an atlas to build a picture site, and use a software model to build a software download site.

Of course, the above models that come with the system are called system models. Users can define some models themselves, such as books, music albums, etc. Only by customizing these models can they build sites with more content forms.

It is equivalent to us automatically adding the table structure to adapt to changes in current needs

10. The following concepts, design and use of templates in dede must be understood Concept

1. Section (cover) template:

refers to the template used by the website homepage or the more important column cover channel. It is generally named with "index_identification ID.htm". In addition, the user For individually defined individual pages or custom tags, you can also choose whether to support section template tags. If supported, the system will use the section template tag engine to parse before outputting the content or generating a specific file.

2. List template:

refers to the template of the list of all articles in a certain column of the website, generally named with "list_identification ID.htm".

3. Archive template:

represents the template of the document viewing page, such as the article template, which is generally named with "article_identification ID.htm".

4. Other templates:

The general system generally includes templates: home page template, search template, RSS, JS compilation function template, etc. In addition, users can also customize a template to create any document.

11. How many tags are used in dede?

List, content, and other tags can only be used within their scope, list tags can only be used in lists, and content tags can only be used in content tags.

Global tags can be used in all pages

12. Familiar with common class libraries

(for example: dedesql.class.php); familiar with system function libraries (common.func.php); familiar with custom function libraries (extend.func.php); familiar with front-end entry files ( common.inc.php)

Back to top

7. WeChat public platform development

1. WeChat operating mechanism

What language is used to communicate between the official account and php: Xml

Weixin.php is How to receive public account data:

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//Receive data XML data

2. Message type

WeChat currently provides 7 basic message types, which are:

(1) Text message (text);

(2) Image message (image) ;

(3) Voice (voice)

(4) Video (video)

(5) Geographical location (location);

(6 ) Link message (link);

(7) Event push (event)

type. Master the data transfer format when sending different message types

4. The function to read the entire file into a string is

File_get_contents

5. Commonly used functions

The function that parses xml data into objects is

simplexml_load_string()

The function that converts a string into an array is ___ explode_________, and the function that converts an array into a string is ____implode________.

The string that encodes the URL string is ____urlencode________.

6. The function of Sprintf function

You can check the manual for this.

7. Why is the WeChat official account unable to provide services?

1. Network reason, data interface reason

2. Code error, how to guess the reason

Check where you modified it, if the code is correct

You can export the data and take a look. Use php to operate files

$myfile = fopen("newfile.txt", "w");

$txt = "aaaaaaaaaa";

fwrite($myfile, $txt);

fclose($myfile);

8. Custom menu event push

Click

Click on the jump link

Scan the code to push the event

Scan the code to push and pop up

# The event that pops up the WeChat photo album sender

The event that pops up the geographical location selector

9. The role of token

Security mechanism verification, used for WeChat server and PHP server Security verification between

10. The role of Appid and secrect


When requesting the api interface (such as menu operation), you need to pass the appid and secrect values ​​to obtain the application authorization code

Back to top

8. Description of the technologies you have mastered:

1. Taking PHP+MYSQL as the direction, proficient in smarty template engine, ThinkPHP framework, WeChat public platform development, DEDE , ecshop and other secondary development systems, have a certain understanding of object-oriented; database, proficient in MYSQL, MSSQL and other databases; familiar with PHP development under Linux

2. Front-end technology: proficient in p+CSS Web page layout, javascript, JQuery framework, AJAX technology, photoshop image processing

3. One year of project development experience, developed 'XXXXXXXX' using smarty, 'XXXXXXXX' using ThinkPHP, and developed using WeChat public platform The public account of the 'Employment Service Network' has used the DreamWeaver system to develop corporate websites, etc.

1. One of the major advantages of the PHP language is cross-platform. What is cross-platform?

The optimal combination of PHP's running environment is Apache+MySQL+PHP. This running environment can be configured on different operating systems (such as windows, Linux, etc.) and is not restricted by the operating system, so it is called cross-platform

2. How many methods are there for data submission in WEB development? What's the difference? Which method does Baidu use?

Get and post two methods

The difference: 1. Get obtains data from the server, post transmits data to the server

2. The value passed by Get is visible in the url, and post Invisible in the url

4. The value passed by Get is generally within 2KB, and the size of the value passed by post can be set in php.ini

5. The security of get is not low, but the security of post Higher, but the execution efficiency is higher than Post

Suggestions:

1. The get type is less secure than the Post type. It contains confidential information. It is recommended to use the Post data submission type;

2. It is recommended to use the Get method for data query; it is recommended to use the Post method for adding, modifying or deleting data;

The get method used by Baidu, because it can be seen from its URL

3. Understand which frameworks, template engines, systems, etc. of PHP

Frameworks: There are many frameworks, such as zendframe, CI, Yii, etc. What we have learned is thinkphp

Template engines: There are also There are many in the textbooks. What we have learned is the smart

system: there are many, such as: Kangsheng's products (uchome, supesite, discuzX, etc.), Empire system, DEDE (Dream Weaver), ecshop, etc. , what we have learned is DEDECMS, Ecshop

4. What are the web front-end technologies you have mastered?

Proficient in p+CSS web page layout, JavaScript, jQuery framework, photoshop image processing

5. What are the advantages of AJAX?

ajax is an asynchronous transmission technology that can be implemented through javascript or the JQuery framework to achieve partial refresh, which reduces the pressure on the server and improves the user experience

6. Safe to one It is very important for a set of programs. Please tell me what safety mechanisms should be paid attention to during development?

① Prevent remote submission; ② Prevent SQL injection and filter special codes; ③ Prevent registration machine flooding and use verification codes;

7. In the development of the program, how to improve the performance of the program operating efficiency?

① Optimize SQL statements, try not to use select * in query statements, use which field to check which field; use less subqueries instead of table connections; use less fuzzy queries; ② Create indexes in data tables; ③ Right Generate cache for data frequently used in the program;

8. Can PHP be used with other databases?

PHP与MYSQL数据库是最优搭配,当然PHP也可以去其它的数据库搭配使用,例如MSSQL等,PHP中预留了操作MSSQL的函数,只要开启就可以使用

9. 现在编程中经常采取MVC三层结构,请问MVC分别指哪三层,有什么优点?

MVC三层分别指:业务模型、视图、控制器,由控制器层调用模型处理数据,然后将数据映射到视图层进行显示,优点是:①可以实现代码的重用性,避免产生代码冗余;②M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式

10. 对json数据格式的理解?

JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,json数据格式固定,可以被多种语言用作数据的传递

PHP中处理json格式的函数为json_decode( string $json [, bool $assoc ] ) ,接受一个 JSON格式的字符串并且把它转换为PHP变量,参数json待解码的json string格式的字符串。assoc当该参数为TRUE时,将返回array而非object;

Json_encode:将PHP变量转换成json格式

14. PHP处理数组的常用函数?(重点看函数的‘参数’和‘返回值’)

①array()创建数组;②count()返回数组中元素的数目;③array_push()将一个或多个元素插入数组的末尾(入栈);④array_column()返回输入数组中某个单一列的值;⑤array_combine()通过合并两个数组来创建一个新数组;⑥array_reverse()以相反的顺序返回数组;⑦array_unique()删除数组中的重复值;⑧in_array()检查数组中是否存在指定的值;

15. PHP处理字符串的常用函数?(重点看函数的‘参数’和‘返回值’)

①trim() removes blank characters and other characters on both sides of the string; ②substr_replace() replaces part of the string with another string; ③substr_count() counts the number of times a substring appears in the string; ④substr( ) returns a part of the string; ⑤strtolower() converts the string to lowercase letters; ⑥strtoupper() converts the string to uppercase letters; ⑦strtr() converts specific characters in the string; ⑧strrchr() finds the string in another character The last occurrence in a string; ⑨ strstr() finds the first occurrence of a string in another string (case-sensitive); strrev() reverses the string; strlen() returns the length of the string; str_replace() Replace some characters in the string (case-sensitive); print() outputs one or more strings; explode() breaks the string into an array; is_string() detects whether the variable is a string; strip_tags() starts from Remove HTML tags from a string; mb_substr() is used to intercept Chinese and English functions

16. What are the commonly used functions for PHP processing time? (Focus on the ‘parameters’ and ‘return value’ of the function)

date_default_timezone_get() returns the default time zone.

date_default_timezone_set() sets the default time zone.

date() formats local time/date.

getdate() returns date/time information.

gettimeofday() returns the current time information.

microtime() returns the number of microseconds in the current time.

mktime() returns the Unix timestamp of a date.

strtotime() parses any English text date or time description into a Unix timestamp.

time() returns the Unix timestamp of the current time.

17. Common functions used in PHP to process databases? (Focus on the 'parameters' and 'return value' of the function)

Please refer to the PHP manual and read it carefully. This item is very important.

18. What are the commonly used functions of PHP to operate files? (Focus on the 'parameters' and 'return value' of the function)

①Open the file; ②Delete the file; ③Read the file; ④Write the file; ⑤Modify the file; ⑥Close the file; ⑦Create file, etc. etc. This item is very important. It is often used to generate cache or static files at work. Please refer to the PHP manual and carefully review

19. What are the common functions of PHP operating directories (folders)? (Focus on the 'parameters' and 'return value' of the function)

①Open the directory; ②Delete the directory; ③Read the directory; ④Create the directory; ⑤Modify the directory; ⑥Close the directory, etc. This item is very Important, in your work, you often create or delete directories for uploaded files, and create or delete directories for cached and static pages. Please refer to the PHP manual and read carefully

3. Object-oriented part

1. What is object-oriented? (Answer with understanding)

Answer: Object-oriented OO = object-oriented analysis OOA + object-oriented design OOD + object-oriented programming OOP; the popular explanation is "everything is an object" ", treat all things as independent objects (units) that can complete their own functions, instead of being divided into functions like C.

The current pure OO languages ​​are mainly Java and C#. PHP and C++ also support OO. C is process-oriented.​​

2. Briefly describe the access rights of private, protected, and public modifiers.

Answer: private: Private members can only be accessed inside the class.

protected: Protected members, accessible within the class and inherited classes.

public: Public members, completely public, no access restrictions.

3. What is the difference between heap and stack?

Answer: The stack is a memory space allocated during compilation, so the size of the stack must be clearly defined in your code;

The heap is a memory space dynamically allocated during program running. , you can determine the size of heap memory to be allocated based on the running conditions of the program.

4. The main difference between XML and HTML

Answer: (1) XML distinguishes between uppercase and lowercase letters, while HTML does not.

(2) In HTML, you can omit closing tags such as

or if the context clearly shows where the paragraph or list key ends. In XML, the closing tag must not be omitted.

(3) In XML, elements that have a single tag without a matching closing tag must end with a / character. This way the parser knows not to look for the closing tag.

(4) In XML, attribute values ​​must be enclosed in quotation marks. In HTML, quotation marks are optional.

(5) In HTML, you can have attribute names without values. In XML, all attributes must have corresponding values.

5. What are the characteristics of object-oriented?

Answer: Mainly include encapsulation, inheritance, and polymorphism. If it is 4 aspects, add: abstraction.

The following explanation is for understanding:

Encapsulation:

Encapsulation is the basis for ensuring that software components have excellent modularity. The goal of encapsulation is to achieve high content of software components. Aggregation, low coupling, preventing the impact of changes caused by program interdependence.

Inheritance:

When defining and implementing a class, you can do it on the basis of an existing class. You can use the content defined by this existing class as your own content, and you can add some new content or modify it. The original method is made more suitable for special needs, which is inheritance. Inheritance is a mechanism for subclasses to automatically share parent class data and methods. This is a relationship between classes that improves the reusability and scalability of software.

Polymorphism:

Polymorphism means that the specific type pointed to by the reference variable defined in the program and the method call issued through the reference variable are not determined during programming, but in the program It is determined during running time that a reference variable will point to an instance object of which class. The method call issued by the reference variable is a method implemented in which class. This must be determined during the running of the program.

Abstract:

Abstraction is to find out the similarities and commonalities of some things, and then classify these things into a class. This class only considers the similarities and commonalities of these things, and Will ignore those aspects that are irrelevant to the current topic and goal, and focus on aspects that are relevant to the current goal. For example, if you see an ant and an elephant and you can imagine how they are similar, that is abstraction.

6. What are the concepts and differences between abstract classes and interfaces?

Answer: Abstract class: It is a special class that cannot be instantiated and can only be used as a parent class of other classes. Declared using the abstract keyword.

It is a special abstract class and a special class that uses interface declaration.

(1) The operations of abstract classes are implemented through the inheritance keyword extends, and the use of interfaces is implemented through the implements keyword.

(2) There are data members in the abstract class, which can realize data encapsulation, but the interface has no data members.

(3) Abstract classes can have constructors, but interfaces have no constructors.

(4) Methods of abstract classes can be modified with private, protected, and public keywords (abstract methods cannot be private), while methods in interfaces can only be modified with public keywords.

(5) A class can only inherit from one abstract class, and a class can implement multiple interfaces at the same time.

(6) An abstract class can have implementation code for member methods, but an interface cannot have implementation code for member methods.

7. What is a constructor, what is a destructor, and what is its function?

Answer: The constructor (method) is the first method automatically called by the object after the object is created. It exists in every declared class and is a special member method. Its function is to perform some initialization tasks. In Php, __construct() is used to declare the constructor method, and only one can be declared.

The destructor (method) has the opposite effect to the constructor. It is the last method automatically called by the object before it is destroyed. It is a newly added content in PHP5 that is used to perform some specific operations before destroying an object, such as closing files and releasing memory.

8. How to overload the method of the parent class, give an example

Answer: Overloading means overriding the method of the parent class, that is, using the method in the subclass Replacing a method inherited from the parent class is also called method overriding.

The key to overriding the parent class method is to create the same method in the parent class in the subclass, including the method name, parameters and return value type. In PHP, it is only required that the names of the methods are the same.

9. What are the commonly used magic methods? Example

Answer: PHP stipulates that methods starting with two underscores (__) are reserved as magic methods, so it is recommended that your function name should not start with __ unless it is to overload an existing magic method. .

__construct() is automatically called when instantiating a class.

__destruct() is automatically called when the class object is used.

__set() is called when assigning a value to an undefined property.

__get() is called when undefined attributes are called.

__isset() Will be called when using isset() or empty() function.

__unset() Will be called when using unset().

__sleep() is called when serializing using serialize.

__wakeup() is called when deserializing using unserialize.

__call() is called when calling a method that does not exist.

__callStatic() calls a static method that does not exist.

__toString() is called when converting an object into a string. Such as echo.

__invoke() Called when trying to invoke an object as a method.

__set_state() Called when using the var_export() function. Accepts an array parameter.

__clone() is called when using clone to copy an object.

10. What do the three keywords $this, self, and parent represent respectively? In what situations is it used?

Answer: $this current object

self current class

parent parent class of the current class

$this is used in the current class, use -> ;Call properties and methods.

self is also used in the current class, but it needs to be called using ::.

parent is used in the class.

11. How to define constants in a class, how to call constants in a class, and how to call constants outside a class.

Answer: The constants in the class are also member constants. A constant is a quantity that does not change and is a constant value.

Define constants using the keyword const.

例如:const PI = 3.1415326;

无论是类内还是类外,常量的访问和变量是不一样的,常量不需要实例化对象,

访问常量的格式都是类名加作用域操作符号(双冒号)来调用。

即:类名 :: 类常量名;

12、 作用域操作符::如何使用?都在哪些场合下使用?

答:调用类常量

调用静态方法

13、__autoload()方法的工作原理是什么?

答:使用这个魔术函数的基本条件是类文件的文件名要和类的名字保持一致。

当程序执行到实例化某个类的时候,如果在实例化前没有引入这个类文件,那么就自动执行__autoload()函数。

这个函数会根据实例化的类的名称来查找这个类文件的路径,当判断这个类文件路径下确实存在这个类文件后

就执行include或者require来载入该类,然后程序继续执行,如果这个路径下不存在该文件时就提示错误。

使用自动载入的魔术函数可以不必要写很多个include或者require函数。

返回顶部

四、ThinkPHP部分

1、常见的PHP框架

答:thinkPHP

yii

ZendFramework

CakePhp

sy

2、如何理解TP中的单一入口文件?

答:ThinkPHP采用单一入口模式进行项目部署和访问,无论完成什么功能,一个项目都有一个统一(但不一定是唯一)的入口。应该说,所有项目都是从入口文件开始的,并且所有的项目的入口文件是类似的,入口文件中主要包括:

定义框架路径、项目路径和项目名称(可选)

定义调试模式和运行模式的相关常量(可选)

载入框架入口文件(必须)

 

3、ThinkPHP中的MVC分层是什么?(理解)

答:MVC 是一种将应用程序的逻辑层和表现层进行分离的方法。ThinkPHP 也是基于MVC设计模式的。MVC只是一个抽象的概念,并没有特别明确的规定,ThinkPHP中的MVC分层大致体现在:

模型(M):模型的定义由Model类来完成。

控制器(C):应用控制器(核心控制器App类)和Action控制器都承担了控制器的角色,Action控制器完成业务过程控制,而应用控制器负责调度控制。

视图(V):由View类和模板文件组成,模板做到了100%分离,可以独立预览和制作。

但实际上,ThinkPHP并不依赖M或者V ,也就是说没有模型或者视图也一样可以工作。甚至也不依赖C,这是因为ThinkPHP在Action之上还有一个总控制器,即App控制器,负责应用的总调度。在没有C的情况下,必然存在视图V,否则就不再是一个完整的应用。

总而言之,ThinkPHP的MVC模式只是提供了一种敏捷开发的手段,而不是拘泥于MVC本身。

 

5、如何理解 ThinkPHP 3.0 架构三(核心 + 行为 + 驱动)中的行为?

答:核心 + 行为 + 驱动

TP官方简称为:CBD

核心(Core):就是框架的核心代码,不可缺少的东西,TP本身是基于MVC思想开发的框架。

行为(Behavior) :行为在新版ThinkPHP的架构里面起着举足轻重的作用,在系统核心之上,设置了很多标签扩展位,而每个标签位置可以依次执行各自的独立行为。行为扩展就因此而诞生了,而且很多系统功能也是通过内置的行为扩展完成的,所有行为扩展都是可替换和增加的,由此形成了底层框架可组装的基础。

驱动( Driver ):数据库驱动、缓存驱动、标签库驱动和模板引擎驱动,以及外置的类扩展。

框架,即framework。其实就是某种应用的半成品,就是一组组件,供你选用完成你自己的系统。简单说就是使用别人搭好的舞台,你来做表演。而且,框架一般是成熟的,不断升级的软件。

 

6、什么是惯例配置?

答:惯例配置上一页下一页惯例重于配置是系统遵循的一个重要思想,系统内置有一个惯例配置文件(位于系统目录下面的Conf\convention.php),按照大多数的使用对常用参数进行了默认配置。所以,对应用项目的配置文件,往往只需要配置和惯例配置不同的或者新增的配置参数,如果你完全采用默认配置,甚至可以不需要定义任何配置文件。

惯例配置文件会被系统自动加载,无需在项目中进行加载。

7、什么是SQL注入?(理解)

Answer: SQL injection attack is one of the common means used by hackers to attack the database. Some programmers do not judge the legality of user input data when writing code. The injector can enter a database query code in the form and submit it. The program will piece together the submitted information to generate a complete SQL statement, and the server will be deceived. Execute the malicious SQL command. The injector successfully obtains some sensitive data based on the results returned by the program, and even controls the entire server. This is SQL injection.

8. How does ThinkPHP prevent SQL injection? (Understanding)

Answer: (1) Try to use arrays for query conditions, which is a safer way;

(2) If you have to use string query conditions, use preprocessing Mechanism;

(3) Turn on data field type verification, and you can force conversion of numerical data types; (Field type verification has been mandatory since version 3.1)

(4) Use automatic verification and auto-complete mechanisms for custom filtering of applications;

(5) Use field type checking, automatic verification, and auto-complete mechanisms to avoid the input of malicious data.

9. How to enable debugging mode? What are the benefits of debug mode?

Answer: Turning on debugging mode is very simple. You only need to add a line of constant definition code to the entry file:

//Turn on debugging mode

define('APP_DEBUG', true);

//Load the framework entry file

require './ThinkPHP/ThinkPHP.php';

In After completing the development phase and deploying to the production environment, you only need to delete the debug mode definition code to switch to deployment mode. After turning on debugging mode, the system will first load the system default debugging configuration file, and then load the project's debugging configuration file. The advantages of debugging mode are:

Turn on logging, any error information and Debugging information will be recorded in detail to facilitate debugging;

Turn off the template cache, template modifications can take effect immediately;

Record SQL logs to facilitate SQL analysis;

Turn off field caching, data Table field modifications are not affected by caching;

Strictly checks file case (even on Windows platforms) to help you find Linux deployment problems in advance;

can be conveniently used at different stages of the development process, Including any required situations such as development, testing and demonstration, different application modes can configure independent project configuration files.

10. What configuration modes are supported in TP? priority?

Answer: ThinkPHP has created its own unique hierarchical configuration mode in project configuration. Its configuration level is reflected in:

Conventional configuration->Project configuration->Debug configuration-> ;Group configuration->Extended configuration->Dynamic configuration

The above is the loading order of configuration files, because the subsequent configuration will overwrite the previous configuration of the same name (without taking effect), so the priority is from Right to left.

11. What are the URL patterns in TP? Which is the default?

Answer: ThinkPHP supports four URL modes, which can be defined by setting the URL_MODEL parameter, including normal mode, PATHINFO, REWRITE and compatibility mode.

The default mode is: PATHINFO mode, set URL_MODEL to 1

12. What are the system variables in TP? How to get system variables?

Answer: How to obtain system variables:

You only need to call the following method in Action:

$this->Method name (" Variable name",["Filter method"],["Default value"])

13. What is the difference between D function and M function in ThinkPHP framework?

Answer: The M method instantiates the model without the user defining a model class for each data table. The D method can automatically detect the model class. If a custom model class exists, the custom model class will be instantiated. If not, the custom model class will be instantiated. exists, the M method will be automatically called to instantiate the Model base class. At the same time, models that have been instantiated will not be instantiated repeatedly (single case mode).

Back to top

5. smarty template engine

1. What is the difference between compilation and caching?

The compilation process of smarty is to take the template and replace the tags inside with the corresponding php code. This is the compilation of smarty. In fact, it is the process of mixing php and html

Smarty’s cache needs to be turned on manually. Smarty’s cache is to execute the compiled file and generate a static html page at the same time. When you access it again, you will access the html file. So in terms of efficiency, it is higher

2. What is smarty? What are the advantages of Smarty?

Smarty is a PHP template engine written in PHP , the purpose is to separate the PHP program from the artist, so that when the programmer changes the logical content of the program, it will not affect the artist's page design, and when the artist re-modifies the page, it will not affect the program logic of the program. This is important in multi-person cooperation. It is particularly important in the project. (It is also easy to develop multi-style programs)

Advantages of Smarty

1. Fast speed: compared with other template engines.

2. Compiled type: A program written in smarty must be compiled into a non-template technology PHP file at runtime

3 Caching technology: It can cache the HTML file that the user finally sees into a static HTML page

4. Plug-in technology: smarty can customize plug-ins.

Not suitable for using smarty

1. Content that needs to be updated in real time. For example, like stock display, it requires frequent data updates 2. Small projects. A small project that requires both an artist and a programmer because of its simplicity

3. Use {$smarty} in the template to retain variables

{$smarty.get.page} //Similar to accessing $_GET[page]

{ in a php script smarty.cookies.}

{smarty.post.}

{smarty.session.}

{smarty.server.}

4. Access variables in php in templates

There are two types of system constants and custom constants in php scripts. These two constants can also be accessed in Smarty templates and are not required Assigned from php, the value of the constant can be output directly as long as the variable is retained through {$smarty}. Example of outputting constants in a template:

{$smarty.const._MY_CONST_VAL}

{$smarty.const.__FILE__}

5. Variable modifier

{$var|modifier1|modifier2|.........}

<{$str} >

<{$str|capitalize}><{*First letter is capitalized*}>

<{$str|upper }><{*all uppercase*}>

<{$str|lower}><{*all lowercase*}>

<{$str|lower|upper}><{*all caps, adjusted from left to right*}>

<{$leg|truncate}> ;<{*String interception, default 80 characters*}>

<{$leg|truncate:10}><{*String interception, first 10 characters , including... three characters *}>

6. When php queries the mysql database, garbled characters appear when querying the Chinese results. How to deal with it? ? ? ?

1. File properties (save as)

2. File meta (when setting up browser parsing)

3. Encoding settings when connecting to the database

4. Use the header function in the PHP file to determine the encoding

7. Caching mechanism

If caching is turned on, smarty will generate a static html page at the same time. If it does not expire within the set time, when you visit again, the page you visited will be It is an html file, which reduces the need to read the database, so in terms of efficiency, it is higher.

8. Smarty’s assignment and loading template

$Smarty->assign(name,value)

$Smarty->display ('index.html')

9.What is the use of smarty template technology?

In order to separate php from html, artists and programmers should perform their own duties without interfering with each other.

10. What are the main configurations of smarty?

1. Introduce smarty.class.php;

2. Instantiate the smarty object;

3. Re-modify the default template path;

4 . Re-modify the path of the default compiled file;

5. Re-modify the path of the default configuration file;

6. Re-modify the path of the default cache.

7. You can set whether to enable cache.

8. You can set the left and right delimiters.

11. What details do you need to pay attention to when using smarty?

Smarty is a template engine based on the MVC concept. It divides a page program into two parts for implementation: the view layer and the control layer.

That is to say, smarty technology combines the user UI with Separate from php code.

In this way, programmers and artists perform their respective duties without interfering with each other.

12. Pay attention to the following issues when using smarty:

1. Configure smarty correctly. It is mainly necessary to instantiate the smarty object and configure the path of the smarty template file;

2. Use assign assignment and display display page in the php page;

3. No php code is allowed in the smarty template file Section, all comments, variables, and functions must be included in the delimiter.

A.{}

B. foreach

C. if else

D. include

E. Literal

Back to top

6. Secondary development system (DEDE, ecshop):

1. Understanding of secondary development

Secondary development, simply put It means customizing and modifying existing software, extending functions, and achieving the functions you want. Generally speaking, the core of the original system will not be changed.

2. MVC

Model (model) data processing.

View template display.

Controller controls the process.

What is the concept of MVC? What are the main tasks of each level?

MVC (Model-View-Controller) is a software design pattern or programming idea.

M refers to the Model model layer, V is the View layer (display layer or user interface), and C is the Controller layer.

The purpose of using mvc is to separate M and V, so that a program can easily use different user interfaces.

In website development,

The model layer is generally responsible for adding, deleting, modifying, and checking database table information.

The view layer is responsible for displaying page content.

The controller layer is responsible for M and V play a regulating role. The controller layer decides which method of which model class to call.

After the execution is completed, the controller layer decides which view layer to assign the result to.

3. Some warnings and errors appear when accessing the secondary development program after installation

Based on the errors, modify the server configuration parameters and Baidu

4 . Functions, replacement of templates, addition and modification of functions

In fact, it is object-oriented application, and replacement of templates is similar to the use of smarty

5. What secondary development things have been used? ?

Dedecms phpcms ecshop, basically if you have a good foundation, it will be no problem to learn.

6. Is it better to do primary development or secondary development like PHP?

Generally, small and medium-sized enterprises use cms system for secondary development, all for the sake of efficiency. Of course, if you want to develop it all at once, you can do it, as long as you know how to use the framework and have enough time. Large companies develop by teams to avoid copyright issues.

7. In the secondary development process, how are the method accesses between many classes transmitted?

It is not class inheritance but object combination. Pass the instantiated objects through global

8. If dedecms changes the directory, a certain item in the background cannot be entered. How to solve it?

Change the background core settings to the current project directory name

9. Do you understand the custom model in dedecms?

There is the concept of content model in the DreamWeaver system. Different content models can be used to build sites with different content forms. The system comes with the following models: ordinary articles, photo albums, software, and products. , classified information, special topics. Through the system's own model, we can use it to build different types of sites. For example, you can use an atlas to build a picture site, and use a software model to build a software download site.

Of course, the above models that come with the system are called system models. Users can define some models themselves, such as books, music albums, etc. Only by customizing these models can they build sites with more content forms.

It is equivalent to us automatically adding the table structure to adapt to changes in current needs

10. The following concepts, design and use of templates in dede must be understood Concept

1. Section (cover) template:

refers to the template used by the website homepage or the more important column cover channel. It is generally named with "index_identification ID.htm". In addition, the user For individually defined individual pages or custom tags, you can also choose whether to support section template tags. If supported, the system will use the section template tag engine to parse before outputting the content or generating a specific file.

2. List template:

refers to the template of the list of all articles in a certain column of the website, generally named with "list_identification ID.htm".

3. Archive template:

represents the template of the document viewing page, such as the article template, which is generally named with "article_identification ID.htm".

4. Other templates:

The general system generally includes templates: home page template, search template, RSS, JS compilation function template, etc. In addition, users can also customize a template to create any document.

11. How many tags are used in dede?

List, content, and other tags can only be used within their scope, list tags can only be used in lists, and content tags can only be used in content tags.

Global tags can be used in all pages

12. Familiar with common class libraries

(for example: dedesql.class.php); familiar with system function libraries (common.func.php); familiar with custom function libraries (extend.func.php); familiar with front-end entry files ( common.inc.php)

Back to top

7. WeChat public platform development

1. WeChat operating mechanism

What language is used to communicate between the official account and php: Xml

Weixin.php is How to receive public account data:

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//Receive data XML data

2. Message type

WeChat currently provides 7 basic message types, which are:

(1) Text message (text);

(2) Image message (image) ;

(3) Voice (voice)

(4) Video (video)

(5) Geographical location (location);

(6 ) Link message (link);

(7) Event push (event)

type. Master the data transfer format when sending different message types

4. The function to read the entire file into a string is

File_get_contents

5. Commonly used functions

The function that parses xml data into objects is

simplexml_load_string()

将字符串转换为数组的函数是___ explode_________,将数组转化为字符串的函数是____implode________.

编码 URL 字符串的字符串是____urlencode________.

6. Sprintf函数的作用

  这个都是可以查手册的。

7. 微信公众号出现无法提供服务的原因?

   1. 网络原因 ,数据接口原因

2. 代码错误,怎么推测原因

       修改的哪里检查一下,如果代码没错

    可以输出数据 看一下。用php操作文件

 

    $myfile = fopen("newfile.txt", "w");

    $txt ="aaaaaaaaaa";

    fwrite($myfile, $txt);

    fclose($myfile);

 

8.  自定义菜单的事件推送

       单击

       单击跳转链接

       扫码推事件

       扫码推且弹出

       弹出系统拍照发图的事件

       弹出微信相册发图器的事件

       弹出地理位置选择器的事件

9.token的作用

   安全机制验证,用于微信服务器与PHP服务器之间的安全验证
10. Appid与secrect的作用

   请求api接口(例如菜单的操作)时需要传appid与secrect两个值,用来获取应用的授权码  

返回顶部

八、对于自身掌握的技术描述:

1. 以PHP+MYSQL为方向,熟练掌握smarty模板引擎、ThinkPHP框架、微信公众平台开发、DEDE、ecshop等二次开发系统,对面向对象有一定的理解;数据库方面,熟练掌握MYSQL、MSSQL等数据库;熟悉在linux下的PHP开发

2. 前端技术:熟练掌握p+CSS网页布局,javascript,JQuery框架、AJAX技术、photoshop图片处理

3. 一年的项目开发经验,使用smarty开发过‘XXXXXXXX’,ThinkPHP开发过‘XXXXXXXX’,使用微信公众平台开发过‘就业服务网’的公众号,使用织梦系统开发过企业站等。

The above is the detailed content of Sharing of key PHP interview questions (1). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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