What I’m Learning- PHP Constants and Operators

Are you looking to use Constants and Operators in your PHP code? Here is a  collection of some things you will need.

Constants

A constant is something that will not be changed, starts with a letter or _ (no $), and can be used throughout script.

Start here:

define(name, value, case-insensitive)

Name: The name of the constant you are creating

Value: The value of the constant you are creating

Case Insensitive: Default is false (meaning if you want to be case insensitive, don’t fill in this portion)

Unlike strings, constants can be inside or outside functions.


Operators

Perform operations on variables and values (words and numbers) in the following groups:

  • Arithmetic operators
    • Simple math problems
    • <?php
      $x = 10;  
      $y = 6;
      echo $x + $y;
      ?> 
  • Assignment operators
    • using = like “x=y+z”, the x is now equal to the equation
    • <?php
      $x = 20;  
      $x += 100;
      echo $x;
      ?>  
  • Comparison operators
    • are used to compare two values
    •  Got this from W3Schools.com, great site for all languages.
  • Increment/Decrement operators
    • The PHP increment operators are used to increment a variable’s value.

      The PHP decrement operators are used to decrement a variable’s value.

  • Logical operators
  • String operators
  • Array operators

Cheers,

The Code Damsel

 

Don’t give up coding 

Coding can be the most frustrating path to go down. I know I have started a project, had it close to completion, and had to start all over. There is good and bad news.

The good, you can Google everything. And don’t feel bad that you don’t remember how to code something, coding isn’t about memorization. It’s about solving a puzzle. Well, more like having a 1000 piece puzzle of all white pieces. But you slowly start coloring in the pieces and they make sense.

The bad news is it can take a while to find the right code. Every code out there will take some personalization to make it work for your needs. Sometimes, you won’t be able to find the answer right away. Instead of making you hate yourself by searching for hours, consider an alternative. I didn’t have the skills to make a slider work using java script, HTML, and CSS. And I spent hours trying to make it work. After s couple days, I finally decided I did not need it as much as I thought I did. I changed my direction, and inserted a gallery (see my other post about this) and you know what? It made me happy.

Coding is a special skill because it’s like carpentry or welding, you get to see your creation. Anything you make, is something to be proud of. It takes hard work, and dedication. Let’s say it loud for the people in the back “not just anyone can code”. Many people think making a website off a template is difficult, but they don’t know what goes into doing that. Never give up. You can do it!

Loves from

The Code Damsel

HTML and CSS Gradient

Hey Guys!

Today I am going to talk about backgrounds. These are a struggle for me, trying to figure out what looks good, what looks professional, and what I am actually capable of.

Here is one cool thing that I did figure out: how to do a gradient background.

Notice how along the sides it goes from white to light blue? One way of doing this is creating an image file that is really thin, and then having it repeat over and over and over again. But, I found a better way.


HTML CODE: put <div id= “grad”> in between the header and the body divs

CSS CODE: well, see the following. Each browser has a different way of reading the code written here, and if they don’t like any of them, the browser will resort to the individual color in the top line.

This was honestly a life saver. Not only does it look cool, but the code takes care of everything for you. If you want to change the colors, just switch them out. No need for the extra steps that an image would take.

OH! and do not forget that this will be the background for the whole website unless you say otherwise ( like how I told the body area to be white)

Have a lovely Monday,

The Code Damsel

My Code Story

Hello World, as WordPress likes to say.

You can find my story about why I am about to graduate college at 20 below in another post. Today I am going to talk about how I became interested in coding. (But here’s another picture of me so you can visualize who I am)

About 2 years ago now, my mom started her own massage business after working as a Starbucks barista my whole life (go mom!) and she realized what every new business owner realizes – she needed a website. Being her tech savvy teen, I searched the internet for the cheapest and best option for making a personal website, something that was so easy even I could do it. We put her website on a platform called eHost, and it worked. It was easy like Microsoft Word, and we only had to drag and drop things where we wanted them.

-see my mom’s massage business here

A few months later my dad purchased an outfitting business in Colorado. The business came with a website, and the previous web designer emailed it to me in a zipped special file. I didn’t know what to do with it, and I learned my lesson. Do not ask professionals that you do not know for help. He charged my dad almost $200 because I asked how to unzip the file. After learning that lesson, I screen shot everything from the previous website (it was still live) and built my dad a site on eHost.

-see my dad’s outfitting business here

I was feeling pretty good about myself, I had created two websites. That was easy. When a family friend, Lisa, posted on Facebook that her web designer was having a baby and she needed to replace him, I jumped at the opportunity.

If you have never worked on a WordPress site before that has been created by a professional, let me tell you it is intimidating. The first night I opened the program, I immediately became overwhelmed. I saw CODE. I did not know how to code at the time. I called Lisa and told her that we needed to change platforms, go back to good ol’ eHost and build her website with templates and drag and drop. Well, instead of listening to me, she called her web designer. I will be forever thankful for her to do that, because he then called me and told me I could do it. All I needed to do was go into the site a little bit, and it wouldn’t be as bad as it seemed. And, he told me I could email him or call him at any time to ask questions. WITHOUT CHARGING ME! Having him behind me gave me the confidence to start working in WordPress and realizing- code is the most interesting thing in the world.

-see Lisa’s website here

Fall Semester 2016 at Montana State University, I took an online digital marketing class. This class went over user experience, SEO, WordPress, and so much more. The class allowed me to dip my toes into the world of code, but I was ready to jump in.

Spring Semester 2017 at Montana State University, I did an independent study for credit based on HTML and CSS coding. My teacher is a guy named Jerry, and the most important thing I have learned this semester is this: it is ok to Google. There is way to much to coding to memorize it all. I built a pretty cool website on Notepad ++ using HTML and CSS (I’ll post pictures here somewhere).

It was the middle of Spring Semester 2017, when Justin from a company called Wise Tail was a guest speaker in my Small Business class. He told us about a program called Montana Code School that would open many doors to companies like his.

I wasn’t going to apply. But I did.

I had my interview, and an hour after it was over I received an acceptance letter ( through email).
So February 2018, I will begin attending the Montana Code School to “jump in” to the code world.

As I learn about Code, I am going to use this blog as a reminder of snippets of code I like, things I want to do again, and lessons that I learn. For the next 30 days I am going to try to post once a day, with some lessons I have learned from my independent study.

Cheers!

The Code Damsel