Intro to Wordpress: Intro to PHP
I am studying Wordpress and PHP with @skillcrush, in this article we cover getting acquainted with PHP!
I am learning with Skillcrush. Please check them out and sign up if you're looking to break into tech!
Receive $250 off your course by using the link above. Use the coupon code: TWIXMIXY
NOTE: this discount is for Break Into Tech + Get Hired package exclusively.
It's the same program I am participating in!
🤓 Greetings travelers! We are studying Wordpress and PHP with Skillcrush. In this article we cover getting acquainted with PHP.
🟩🟩🟩🟩🟩🟩🟩⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ 42% DONE
42% of the way done with this course. I’m not sure if it will be possible, but I’d really like to be done by August!
Again… still fielding lots of recruiter calls. Had several interviews as of late as well. I definitely have found it frustrating at times working with either recruiters or companies directly. They definitely have high expectations of the applicant to be available all the time and ASAP, while there is no accountability on the employer side. Unfortunately it can be a lot of wasted time on the end of those who are looking for work.
Alternatively for the past several weeks I’ve been seriously considering enlisting in a full time immersive bootcamp to learn full stack MERN development. This will re-hash the front end dev that I’m already getting familiar with and then will dive deep into backend as well. I have a few more meetings this week to determine if it’s possible, but I’m definitely excited at the thought!
Continuing to make gains towards my fitness goals. I have a game coming up in a couple weeks. Charlotte Roller Derby versus Low Country on August 5th. Let me know if you are interested in coming out to watch!
You can subscribe without signing up for a substack account! Also just select “None” when subscribing. All the content from my learning journey is free.
Intro to PHP
😮💨 whew! They really pack it into these courses sometimes. I’m so glad I took JavaScript before this so I have some concept of what they are talking about.
Data Types:
“Strings”
Numbers: 1234
arrays(‘one’, ‘two’, ‘three’)
Boolean: true/false
nil or null (aka nothing)
Variables
They store pieces of data. Not that they can vary! aka change. Symbolized by the $ sign.
$first_var = "This is a string";
$second_var = 24;
$third_var = true;
global $second_var;
define('FIRST-CONSTANT', 'This one cannot change');
Variables are usually all lowercase. Constants appear to be uppercase mostly.
Printing
We want to be able to output our variables and data. This is done through the echo
method.
<?php echo $myvariable; ?>
Printing an array:
<?php print_r($myarray); ?>
Loops
The basic concept is to set up a series of things that need to happen. Stick them in a loop and pass them through the application. The data will iterate through until it’s all done.
Loops are prolific throughout WordPress.
<?php
while (1 > 0) {
echo "It's true!'
}
If / else
These statements are to ask PHP true/false questions. If this, then that. If not, then other.
$my_var = 1;
if($my_var == 1) {
echo "My variable is equal to one!";
} else {
echo "My variable is NOT equal to one!";
}
Functions
These are code packets of action. It starts with a function declaration where you create the action needed. Then you need to call on that function to execute it.
<?php
function myFunction() {
echo "Hello, Skillcrushers!";
}
myFunction();
Programming Fundamentals Cheatsheet
Skillcrush throughout the course provides cheatsheets. I like to save them to my google drive under a Skillcrush folder where I can quickly search the documents for something I may need.
In this cheatsheet they do a deep dive into the content I just discussed above. And I’m sure they make a lot more sense in how they describe it!
Commenting PHP
As a recap, we comment in HTML as:
<!-- comment here -->
And comment CSS as:
/* comment here */
In PHP there are a couple ways to make comments and notes.
Context Comment
You can make a comment within a piece of code, maybe to give it context.
<?php while ( have_posts()) : the_post(); //context comment here ?>
Deactivate Comment
You can comment out or deactivate an entire line of code.
<?php //while ( have_posts()) : the_post(); ?>
‘C’ Style Comments
You can also use ‘C’ style comments that are used in CSS.
<?php while ( have_posts()) : the_post(); /* c style context comment here */ ?>
‘C’ style comments can be quicker to comment out multiple lines of PHP code.
<?php /* while ( have_posts()) : the_post(); ?>
<?php get_template_part('content', get_post_format()); ?>
<?php comments_template(); ?>
<?php endwhile; */ ?>
WARNING: if you have mixed lines of HTML and PHP, then PHP will still execute when commenting out the HTML surrounding the lines of PHP.
If you want to comment out both you will need to combine using the HTML comment and ‘C’ style comment.
Well that’s enough for now! Glad to have learned a bit of how to code in PHP and how to manage the comments there-in.
Have you ever tried to learn PHP before? How do you like it? Share below!
What did you think? Leave me a comment and share!