Tag Archives: PHP

Oh, PHP

After a lot of stress that culminated during the past week, this one has been quite refreshing. Even moving away from Codecademy for just a couple of days enabled me to discover different online resources, such as the learn-php.org, where I could study the Hypertext Preprocessor (PHP).

There are many programming languages out there, but the PHP language turned out to be a good skill to acquire. Especially due to the fact that it is widely used by the majority of the web. As I found out, it is useful in creating web pages written in HTML and particularly convenient in the process of creating dynamic content. It is also quite swift and easy to adjust, which makes it a pretty cool resource.

While writing this post I silently count down the days to spring break. Even though I will still have to go to work, having at least one long weekend is a very exciting concept to look forward to. In order to make this time more productive, I will try to get ahead on some of my classes in school. On the academic level, making most of spring break would include reviewing the materials I have covered thus far. I will also go through the lessons from Web Development in order to make sure that I did not miss out on any significant knowledge during the busy school term. I feel like this would provide me with a solid foundation for the final project site that is due in April. Even though it might seem like it is far away from now, I believe that if I were to stop using and studying the languages I have learned so far, it might eventually be hard for me to complete the project to the level I would be satisfied with. On that note, I think that revision is an essential part of this class as well as a skill, which could help me in the future.

PHP

Learning PHP was interesting. I’ll echo a lot of my other classmates in saying I did realize it was a bit repetitive at times. And although I initially thought the work put into executing simple equation solutions was worth far less than the effort, when I take into account the mass production aspect of PHP, I’m more understanding.

The first meaningful tool I acknowledged though the lessons (taking them consecutively) was the strlen function to split strings into a more digestible and readable format.

For the language and technical definitions, I think the single section explaining the basics was helpful in the Objects lesson. Classes define how objects behave (and don’t have data). Objects have data. Members are variables that belong to an object, while methods are functions that belong to an object with access to its members. And constructors are methods that are executed when an object is created.

What I’m still a little fuzzy on is the concept of inheritance and private and public functions. I was able to complete the lesson, but it’s not as clear, getting to the final product without having to walk step-by-step with corrections, as I want it to be.

I’m really interested in seeing other ways PHP is used — both within the realm of this class and out of curiosity for possible future endeavors. Again, the example with the phonebook was an eyeopener as to how mass, large tasks could be done with PHP functions.

I was also wondering why, although PHP includes Javascript, HTML and PHP code, it’s free software. I was dong a bit of research and found certain licensing options, and I also found that earlier this month (Feb. 6) there was a new stable release for version 7.3.2 (not entirely sure what other functionality is involved in the latest version). But why’d the three (I believe) originators of what’s now common use PHP write a general purpose scripting language without having at continuous licensing (or at least a one time purchase) associated with its usage? I presume the more I learn about PHP’s capabilities, the more I’ll know why it could possibly for the pure benefit of fellow programmers not bound by a profit driven model.


I think the most recent lesson was really helpful for tackling areas where we were getting stuck when working the slider. The video recording of the lesson addresses all of my questions, many of which I didn’t know how to ask online.

PHP is friendly to learn

PHP was a lot of fun to learn and I really enjoyed it. I did, however, find the logic behind it a little bit redundant. I had to go over the code multiple times to understand the logic. I ended up copying the code from the top into the exercises most of the time and running it in order to see how it comes out and why. The language is also aesthetically ugly and has a slow speed. Most recently, however, there have been many changes to PHP and a tremendous speed gain. Generally speaking, PHP is an easy language to learn and tutorials are very common and often quite good, so I was not sure why I had a hard time with it.

I was curious to learn why software developers used PHP so I started reading more about it. Many developers like it, but others really do not. The language is mostly used on the server side, so it runs on the web server software. The name PHP initially stood for Personal Home Page and then later it changed to Hypertext Preprocessor.

You can do anything with PHP including blogs, scripts to process data, writing desktop applications, etc. The bottom line with this particular language is that PHP is everywhere, so a lot of extremely popular software is written in using it. WordPress is the biggest example that uses PHP. It is low cost and accepted globally, so you can use it in all website development. It also supports a wide range of databases.

It is important to note that it is super easy to change PHP to HTML. You would simply have to convert .html to .php and tweak the inside of the code a little bit to include <?php and ?> in the body. PHP is definitely evolving in many different ways since it is that widely used. It is becoming more Java-like object-oriented language. The most important language to compare PHP to is JavaScript. In modern development, we need a little bit of JavaScript for client-side development.

I want to take some time to explore WordPress and see how PHP is utilized there. I have never worked with WordPress before so this is a great opportunity to put the two together in order to understand the bigger picture. I am going to start using Drupal more often so I want to see how PHP is used there as well.

 

Making sense of PHP basics

I was nervous about being introduced to the PHP basics after the amount of time it took me to finish the gallery assignment. Another web development ingredient thrown into the mix sounded to me like a disaster in the making. This week I tried to make more sense of the purpose of PHP and I decided to turn to metaphors. The metaphor is, “the website is the restaurant and PHP is the cook who serves up a particular dinner order made from a set of ingredients. HTML is like the food on your plate when it arrives. CSS is like the restaurant decor- the color of the plates, the placement of the lights and table clothes, the quality of the silverware and the outfit of your waiter.” I understand that PHP is a server-scripting language, but wouldn’t that mean that every website requires PHP? With this metaphor in mind for the creation of websites, you can’t have a restaurant without a cook making the food. After learning a little bit about PHP in last week’s class, I feel like it would be helpful for me to reinforce the purpose of PHP with a website and then examine the impact PHP has on that website. This will definitely be one of my questions in tomorrow’s class so stay tuned!

Another thought about PHP is that it seems awfully similar to JavaScript in some aspects. For example, the “$” and for loops. I know there are some web developers that like to do HTML, CSS, and JavaScript on one file, but how do you avoid getting confused between PHP and JavaScript especially as a beginner? Is PHP basically a version of JavaScript, but for back-end purposes? Are there websites that are robust without PHP or does PHP help make the world go round in the web development world?

Is it ever helpful for beginners to understand back-end before front-end?

I found this chart on a website defining the difference between JavaScript and PHP and I thought I’d share to help other students:

 

 

HTML with a twist = PHP

Reflections on PHP

There is striking similarity between this week’s PHP lesson and HTML. But for a few differences in the syntax structure and functions, the two seem the same in my opinion. Needless to say that while HTML is a text markup language, PHP is a back-end programming language otherwise called a server-side programming language. It is fair to say a person must necessarily understand HTML and maybe CSS before taking on PHP. I also think just like transitioning from JavaScript to jQuery, a transition from HTML to PHP will be smooth and easy to comprehend, since both programs use almost same logic in concatenating among others. I discovered in my readings that, there are two different schools of thoughts among programmers on whether a person need to learning JavaScript before PHP or PHP and then JavaScript. I find that fascinating, because for me, despite the functional similarities between the two, it doesn’t really matter which one a person learns first. I will want to know what you guys think as well. I referenced a few resources on YouTube for further clarity, but ended up stopping along the way.

Challenges

A few challenges on understanding the logic behind the For loop and While loops. Also on simple arrays, it was a bit of a struggle to comprehend the logic behind the array slice and splice.

Learn-php.org

The website seem fairly basic with lots of advertisements, which are sometimes distracting, but they do acknowledge it’s still under construction so that’s fine. After all, they are offering their services for free.

 

 

PHP

For this past week’s lesson regarding learning PHP, I was initially expecting to use Codecademy, but was surprised that we were using another website — learnphp.org. I was not sure what to expect, but was happy to learn that PHP was essentially another language similar to HTML. So it started off for me as relatively simple, as most of the lessons do. However, I think that maybe I was getting accustomed to Codecademy and the interactiveness of the lessons. The lessons on learnphp.org were more difficult to understand the actions that I was doing and involved more of an attempt, attempt, look for the solution, try to make a correlation and then move forward approach.

One of the confusing things for me, or at least I know it will be confusing to execute along with other languages, is that PHP does not use carrots to open and close like HTML. Instead, it reminds me more of CSS with the semi-colons as separating elements. With the variables and types section of the lesson, it was nice to see a bit or repetition with the basic elements as a way to reinforce older lessons that were learned earlier in the semester. Specifically, the boolean values as true or false, and the strong formatting as a means to command multiple things at once. Hearing the terms over and over again was helpful because I feel that this is one of those things that you have to do everyday otherwise you forget everything you learned the day before, just like math. The arrays in the lesson plan seem easier than the ones we were learning in previous lessons because there were less of the ambiguous, or at least to me, symbols such as the curly braces, brackets, additional parenthesis, and so on. I do think that I will have to go over the lessons once again to better understand the material like I did with Codecademy before we finished our gallery assignment.

Here we go again…

Week six marked the introduction to PHP, a scripting language which, on its surface, seems relatively easy to understand. But we’ve been down this road before (JavaScript, I’m looking at you), and I know better than to assume PHP will become a stress-and-error-free part of my life as it relates to web development.

In fact, while the first lessons were easy enough, I stumbled over the exercises for While Loops, Functions, and Objects. For the most part, these issues arose from syntax errors, which tells me I haven’t seen or used enough PHP to know better (do you ever just “know” this stuff?).

There was something familiar about the lesson on Objects, though: the idea of public and private functions reminded me of the local and global scope concept from Javascript. I appreciate the literal nature of this concept in PHP—you can just call something a “public function” to designate it as such, rather than relying on its placement within the code as you would have to do with JavaScript.

A note about learn-php.org: Though it’s not as pretty as Codecademy, I found the lessons easy to navigate and complete. It also serves as yet another example of the web development world’s emphasis on the free flow of information. I’ve enjoyed our little peeks into the world of web development: the importance of community in solving problems (GitHub, Stack Overflow), the “laziness” of developers (copy and paste whenever you can), the preference for simplicity. Halfway through the semester I’m now reminded of some of the takeaways from our Week 0 pre-readings. Here’s to keeping these lessons in mind as we stare down our final project in the weeks ahead.

An update on the midterm profile assignment: I found my subject, VM Vaughn, through this article on Medium. Vaughn began learning to code at the age of 56, and told me before our interview that he doesn’t consider himself to be a “real web developer.” I was anxious to talk to him about what impact his age has had on his experience learning to code, and what, exactly, a “real” web developer is, anyway. More on that later.

Progress (Sort of)

My site is coming together. Well, sort of. I have a lot of pieces floating around in cyberspace. The biggest piece, however, is my first customization: the interactive map. I downloaded the Leaflet map plugin, which uses an open-source JavaScript library for creating interactive maps. The API is pretty well documented, but there are some things I couldn’t figure out.

Once I input the shortcode to create my map at the location I wanted it and then created the marker for one of my sites, I was able to figure out how to program it to include photos on the markers. But I quickly realized that I did not understand the interface. Before I installed the plugin, I was convinced that I had missed the mark and that none of my customizations would be code customizations because they could all be done with plugins. When I started the work, I figured out that you can type code into plugins (duh). Then, I realized I don’t understand the relationship between plugins and APIs.

Troubleshooting my map plugin helped to give me a basic understanding. I know that a plugin contains groups of functions and is written in PHP. I know that the Leaflet map plugin uses a JavaScript library. This part confused me. When I was writing code for my map, I was confused about which type of file to create in Sublime Text. I settled on JavaScript but as I was typing my code, my mind wandered to if I should create HTML and CSS files to accompany it. At that point, I knew I was overthinking.

Though the map plugin boasts about its well-documented API, it’s still a little hard to understand for me as a beginner. It has lists defining elements, events, methods, and options, (?)  but I get confused about what exactly to type since programming is very specific.

I also had problems with issues with FileZilla. When I tried to connect, I kept getting an error message.

I have one lingering question. What is the relationship between an API and a plugin?

PHP + Design Thinking

This week, I struggled with PHP. I think it was more of a conceptual struggle. I didn’t know what to add to my homepage with PHP. I thought of it as a background language. I don’t know how to differentiate between languages that have functions that just spit out an answer, and languages that have clear functionality. I don’t understand the functionality of PHP. On web searches, I discovered how to make it spit out a date, and I saw that people used it to create forms but not how they implemented it into a page to do something.

Anyhoo, I added some PHP functions that I saw on the Internet and felt could be useful but didn’t see how they’d incorporate. However, on another web search I found resources like this one  that showed me a couple different uses.

Something that stood out to me in the readings today was the design thinking piece. I thought it was especially interesting because at ONA, one of the workshops we participated in was focused on design thinking. We were brainstorming different disciplines within journalism. We wrote each discipline on a sticky note, and then categorized them. Later, we tried formulating a new way to tell a story incorporating four stories from different categories. That workshop was helpful for me because having the problem and the solutions set out in front of me made them so much easier to conceptualize.

I thought it was interesting that designers have been harboring their way of thinking and the rest of us are just now catching on because some of it gave a new name. The piece and my experiences at ONA both made me want to delve deeper and find more creative ways to tell stories as a journalist.