Developing WordPress for beginners: learning PHP

Becoming a WordPress developer is closely related to learning PHP based on the popular server-side scripting language WordPress. PHP, originally created in 1994, is a powerful free open source tool for creating dynamic, interactive web sites. The college has added new courses! Don’t you want to try? Free! Find out again. This is the second post in the 5-episode series for beginners. It teaches you the basic concepts of WordPress development. You can jump from a tinker to a developer. At the end of the series, you can create your own basic themes and plug-ins and concretize them into your own functions. The
In this tutorial, we will learn the basic syntax and working principle of PHP, and introduce you to coding examples. Note: for this series, you must fully understand HTML and CSS. Because both languages are necessary building blocks to use WordPress. Let’s go. Have you missed the word press development series for beginners? You can view all 5 posts here. Develop WordPress for beginners: start developing WordPress for beginners: develop WordPress for beginners learning PHP: develop WordPress for beginners building themes: develop WordPress for beginners building widgets and menus: what is refresh building PHP? PHP is a server-side scripting language. To understand what this means, let’s compare it to HTML. The
If you visit a simple HTML page, the browser makes a request to the server that contains the page. The server determines the required files and sends them as is. The browser parses and displays the HTML code. In contrast, if you visit a PHP page, there are other steps. The browser sends a request, and the server finds the required file. Before resending, the server will process the PHP file to generate the final HTML output. It is retransmitted to the browser and displayed as usual. That’s why even if the site is written in PHP, you can’t view the source code of all sites. You can only View HTML if you view the PHP code. The
So why does the server perform processing? What’s the use of this? You can create dynamic web sites and write code more efficiently. Let’s give two simple examples. In HTML, everything is static. You can create a page that displays \
Another good example is another site that provides twitter or user authored content. If twitter only uses HTML, someone needs to quickly regenerate twitter seeds every time it is published. Time is not valid. With about 1billion twitter accounts, the company needs 1billion HTML files per user somewhere in the folder. PHP can solve the problem of seed regeneration with several files (only one file can be used). Later in this guide, you will return to this example again. The
What I want to say is that in the early stages of learning PHP before you start, you may not understand whether it is relevant to the website. This is a completely normal reaction, just like what I thought when I first started learning PHP. The first step is a bit abstract, but at the end of this article, you will see the light. Test and practice what you want to learn in this tutorial
Apache server is required. This can be an online test site, but it can also be a local server. It is recommended to create a local test server. The method is as follows: The
First and install VirtualBox and vagrant. Create a directory anywhere on the computer where you want to save the project file. There is a \
Key points of loading b5d7ecd113e3107aedbe6b7103e063fc 700MB operating system and installation. It will take some time to complete. Just wait once, so buy cocoa when you’re done. After completion http:\/\/192.168.33.21 Can access the site. After restarting the computer, you must navigate to the default project folder of the terminal, enter vagrant up, and restart the server. The default project file is now the root folder. Index containing content. Create HTML files and web sites http:\/\/192.168.33.21 When accessing, you must render correctly. The
The first step is to look at the PHP tags, variables, values, and eco. Index to the main project folder. Create a PHP file and enter \
The code on the load summary 4075 ec96709c39b2e404 shows the usage of PHP tags and eco. The eco value indicates the PHP display. The result of the above code is \
Load summary 4075 ec96709c39b2e404 stores the \
. You must change the names of all variables to $postdata. The name of the parameter is available anywhere in the function. At the bottom of the code, you can see that the post is displayed more neatly. Just display_post ($post). Well, I’m sure you’re confused about the name. Why is one place $post and the other $postdata? Let’s look at the code. Functions only run at call time, so the first thing that really matters in the code is the definition of the $posts array. Then, create the ring as before. The variable containing the data of a single post in the ring is $post, which has not been changed in the example where there is no function so far. Now, it no longer contains a lot of code, but simply performs functions. Call the display_post() function. You know, you need to pass some data, that is, the data in a single post. Which variables currently contain relevant information$ The post variable is imported from the ring definition. Then scroll to functions. Run now. The first parameter in the function is named $postdata. This simply means that in the function, the data passed to the first parameter is referenced as $postdata. Summary create functions can have multiple parameters and default parameter values. Let’s create a function that cuts all the text into pieces and makes it an excerpt. We want our function to be as flexible as possible to control the extraction length and the string to be added to the end. The first parameter is created as the text to be shortened, the second parameter controls the length, and the third parameter is created as the added text. We will provide the framework for the function and begin. The load summary 4075 ec96709c39b2e404 parameter specifies the default value. That is, you can call a function without passing the second and third arguments. This assumes that the function wants to create a 200 character excerpt and add three points later. Let’s externalize this feature. Load summary 4075 ec96709c39b2e404 I have added many new things in it. Let’s take a closer look at each new addition. Start with an IF statement to confirm whether the given text is longer than the actual given length. This is done using a function called strlen () built into PHP. This function takes a string as an argument and returns the length$ If text length is less than $length, only text is returned. We’ll talk about what returning means later. Otherwise, create the excerpt using the substr () function. This function requires three parameters: text, the starting position of the block, and the length of the block to cut the string and import the block. We added 0 and $length because we wanted to cut the $length character from the beginning of the text. Finally, add an additional string at the end. To do that= Symbols are used. This is $exercise=$exercise$ Same as creating append, $execrpt=$execrpt$ Append $execerpt = $execerpt$ Append The last line returns the $extract variable. So what do you want to return? So far, most of us have caused repercussions, but in most cases, we don’t want to show \

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *