Ch1/intro PHP and MySQL for Dynamic Web Sites

Knocked that one out! Woohoo, I’m excited for php, and have gained a lot on much wanted/needed info regarding it. First off I would like to say that I had asked my JavaScript teacher how php in integrated before we went on break and he responded, “they go in php tags like JS goes in script tags”. Of course I went on to hit with a barrage of questions following that statement, the first and foremost being, “can/will I link an external php file?!?!?!”. His response was almost non existent… probably because he knew that it would keep me up at night thinking which would eventually lead to studying and blogging. Well here is the answer (currently) php is ran server side and consists in your html like any other tag right where it needs to be, when your site is pulled up the php has done its job and is now (in most cases) html markup. I also had been wondering a few more things like why use php over JavaScript, is php like other languages I know, and is php going to allow me to make log in’s? Well first off I discovered many good reasons to use php over JavaScript, the best reason being that its run server side, this means you rely less on the clients setup and more on your own while simultaneously boosting privacy. I also discovered that I will be able to create user accounts and log in’s with php; furthermore I wont have too hard of a time doing so it seems because php is very much like other languages I have learned. I was amped to see how php was written! First of all php is , like I stated before, put in a tag… a pelf closing tag of sorts.

<?php?>

OK easy enough. In context this would be somewhere in the body of your html markup and the actual content would go where I put “content goes here” in the following example…

<?php “content goes here”;?>

Notice the ; which much like other languages runs the function.

 

In the first chapter alone I have gained the ability to…

  • Utilize the php tag properly
  • Make comments (but sublime has my back anyways)
  • Set variables using $
  • Use strings and concatenate them using .
  • Handle numbers and operates such as round()
  • Use constants using define (CONSTANT,value)
  • How to “properly use ‘single’ and /”double/” quotations” 

I also learned that I need to use .php over .html when using php like this, and also learned a bit about debugging. I found something interesting too, it sounds like I have to run my site on a server and not local for php to work, I will worry more about that come class time though given the fact I can learn seamlessly on codecademy.

<?php

define (FEELING, ‘Happy’)

?reason = ‘I finished my chapter one’

echo “<p>”I am feeling ‘ . FEELING . ‘ because ?reason !</p>

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s