Commit 07b8bb80 authored by Mike Street's avatar Mike Street
Browse files

FE: Futher blog and content updates

parent b0fb5424
---
title: Public Relations
date: 2011-03-16
updated: 2016-04-08
intro: Sometimes I wish we lived in a musical. Not not necessarily with all the singing but just with all that general happiness.
permalink: "blog/public-relations/"
tags:
- General
- Thoughts
---
Sometimes I wish we lived in a musical. Not not necessarily with all the singing but just with all that general happiness.
Ive commuted too and from work, be it on trains or buses, and many a time i've wanted to spark up a conversation with someone. This is normally from something theyve said to someone else, something their doing or just for some general chit chat. For example: as I write this, a girl/lady is sat opposite me (lets call her... Victoria \[were on a train headed to London Victoria\]). Now Victoria emerged from the toilet not too long ago, with red eyes and she was sniffing. This was joined by a sad look on her face. Now, shes either upset or on some sort of substance, but due to her posture and behaviour, Im guessing the former.
See in a musical or film, the man would check if shes ok, or crack a joke, or show a funny picture on his phone to make her smile. Anything to brighten her day, anything to lift her moods from playing with the demons that they are evidently frolicking with at the moment.
I know if I was Victoria, the random act of kindness from a stranger would lift my mood. Just the thought of someone nice out there willing to go out of their way to make me smile would certainly reinstate my faith in the world.
But alas, with today's stalkers, touchers, murders etc and societies perception of all men only being out there for one thing and that would be the only reason for them to talk to a stranger, prevented me from doing so.
However, I think if we work together. If we try and break that barrier, that taboo of talking to strangers for no reason, then everyone would be happier. You would get to work with a smile on your face, or you would return home with a new joke. The world would be so much better.
So next time you see a Victoria, go on and make this life a musical.
---
title: Points mean Pixels
date: 2012-02-29
updated: 2021-09-19
intro: Points. A simple, barely-a-conference conference. For ease of reading, this post will follow a traditional approach with a modern twist: Who, What, How Much, Where, When, Speakers, Sponsors Why.
permalink: "blog/points-mean-pixels/"
tags:
- Web
- Events
---
Points. A simple, barely-a-conference conference.
For ease of reading, this post will follow a traditional approach with a modern twist: Who, What, How Much, Where, When, Speakers, Sponsors Why.
## Who?
Points, is me. I am Points.
## What?
For those that know of me and my ventures,  you will be familiar with the event I put on near the end of last year (13th October to be precise) at the Brighton Media Centre. This event was an informal, free 'conference'. It allowed people who had never spoken before to speak and was aimed at all web related folk. To be honest, it was open to everyone, but non-web people would have been bored.
Last time [Paul Davis](http://www.twitter.com/pauladamdavis), [Alex Sexton](http://www.twitter.com/therulebook), [Kris Noble](http://www.twitter.com/simianstudios) and [Anthony Killeen](http://www.twitter.com/mrqwest) all spoke. Several people were kind enough to blog about the event, and you can read the opinions of [Kris Noble](http://simianstudios.com/blog/post/points-brighton), [Anthony Killeen](http://mrqwest.co.uk/blog/181/points-brighton) and [Mr Clive Walker](http://www.cvwdesign.com/txp/article/463/an-evening-out-with-points-brighton) on the event.
So, now that you are all clued up on what Points is all about, let me show you why I am blogging about this age-old event.
> Evening ladies and gents. After a warm, gentle winter the points beast awakens for the spring. Keep April free!
> Points (@PointsBrighton) [February 25, 2012](https://twitter.com/PointsBrighton/status/173491236215336960)
## How Much?
As I mentioned, the last Points was free. However, I learnt my lesson and because of the basic human instinct, the natural emotion of getting free things the last event sold out. Now I bet your wondering 2 things:
1. how can a free event sell out and
2. whats wrong with that?
A free event can sell out if I say I have 50 seats and 50 people say that they're coming. The problem with that is that 20 people turned up. They were 20 wonderful people who made the event spectacular, but the sponsor providing the drinks catered for 50 people unnecessarily.
This was because of the freeness - nature educates us to get free things, so people booked a place and then could decide later if they're coming.
So, because of this, the next points will be a small amount of £5. £5, I feel, is enough for people to make sure they want to come and means I can pay the speakers their bus fare home.
To make you feel a bit better, when all the money is in, costs will be covered and the profits will got to a charity. Maybe that will convince you to spend that £5, if not, a little more.
## Where?
This is the first question I cannot answer. I am after a small space, preferably with Wifi and a projector. It also, really, needs to be in Brighton. If you know of a suitable place, please [let me know](http://www.twitter.com/pointsbrighton)! I am open to any suggestions and will consider anything
## When?
At the moment I am considering mid/end of April, but this is completely down to the venue. I will [keep you posted though](http://www.twitter.com/pointsbrighton)!
## Speakers
Speakers are the easiest to find. Everyone wants to talk and would love the opportunity to give it ago. I've (hopefully) already got the speakers lined up. The subjects i've got in store for you are range from SEO to Typography and a couple of other winners!
## Sponsors
Where speakers are the easiest to find, sponsors are the hardest. All you have to do is ask, but a lot of people say no.
## Why?
The hardest question out of this list to answer. There are not enough cheap conferences, there are not enough reasons to meet up and learn. Meet ups are great and this is just another reason to talk face-to-face about anything nerdy without feeling guilty. The thing I love about this industry is that everyone wants to share. You spend weeks developing something and the next day give it out for free. I love it and I want to give something back. Because of that, Points was born.
---
title: Github for PC and setting up a local testing environment
date: 2012-05-05
updated: 2021-09-19
permalink: "blog/github-for-pc-and-setting-up-a-local-testing-environment/"
tags:
- Web
- Git
- Geekery
---
<div class="info"><strong>Note</strong>: This post is from 2012 this is no doubt ouf-of-date. I've not used Windows since 2014 so cannot verify how accurate this post is.</div>
## The Quick Way
1. Install [XAMPP](http://www.apachefriends.org/en/xampp-windows.html)
1. If on Windows Vista or 7, install it in your user folder
2. Install MySQL and Apache as a Service
3. If after installation Ports 80 and 443 are busy open Skype, Options -> Advanced -> Connection -> Uncheck the box
2. Download and install [Git for Windows](http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git)
3. Download and install [Tortoise Git](http://code.google.com/p/tortoisegit/)
4. Open up PuTTY Gen and generate a key
5. Go to Github -> Options -> SSH Key -> Add New and paste the long key from PuTTYGen into the box in Github. Name it something that represents your computer
6. Save the Private key somewhere as key.ppk
7. Navigate to folder where you want the repository, right click and select Git create repository here...
8. Right click again and go to TortoisGit -> options
9. Select Git on the right hand side, fill in your name and email
10. Select Remote from the left hand side
11. Fill in a name, the git URL (found at the top of the repository on Github) and browse for the private key you saved, Save.
12. Right click in the folder, tortoisegit -> pull. Click ok
13. Edit Files.
14. Right click -> commit to master
15. Click push on the bottom left of the screen once completed. Click ok.
The Long Way
------------
Unlike mac - there isn't a simple 'Github for Windows' application (at time of writing). \[**Edit:** [There now most definitely is](https://desktop.github.com/)\] However, setting up Github to work on your pc is possible. More complicated than the mac app, but you do get more of an understanding about what git is.
This tutorial is not about what git is, its some instructions on how to get things working.Oh. and also - people do use windows machines for development. Deal with it.
With this tutorial, I'm going to go from start to finish - from setting up a local testing environment, right through to the github stage. If you already have something like XAMPP or wamp installed on your PC, you can skip the first bits.
### Setting Up A Local Environment
HTML files work fine on a local machine, however, when you come to running PHP files, normal windows can't handle it. For that reason you need to set up a local environment, or sever. This allows you to run PHP to your hearts content and even build databases if you want!
To do this, my recommendation is [XAMPP](http://www.apachefriends.org/en/xampp-windows.html). (Believe me - I tried them all. XAMPP is basic but horrible looking).
Download the windows installer and follow the steps. If you are on Vista/Win 7 - i suggest installing it in `C:\Users\YOUR USER\xampp` as it sometimes struggles to install it on the `C:\`
Make sure both Apache and MySQL are installed as services. It makes life easier.
It takes a while to install. Go make a cup of tea or something.
When its installed and you start Apache, you may get a windows firewall message. Accept that.
You might find that after installation, it says it can't start Apache because something is using the port. The main cause I've found is Skype. If you have it installed, open up the options, then advanced and then connection and uncheck the box that says about using port 80.
All things being well you should be able to navigate to `http://localhost` in your browser and view the files. The files are located in `C:\Users\YOUR USER\xampp\htdocs`
### Setting Up Git
The next thing you need to do is download and install git.
Head over and download [Git for Windows](http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git)
The only thing to note is to set the option to 'Run Git from the Windows Command Prompt'
The next step is to download and install [Tortoise Git](http://code.google.com/p/tortoisegit/)
When installing. make sure you tick 'Tortoise Plink' on the option
Once the installation has finished, you won't notice any change, except when you're on a windows explorer window, there is some new options to the right click menu.
### Pulling, Committing and Pushing
Firstly, we need to generate some random keys, a public and a private one. These are used so that Github knows its you. The public key is used by Github to check against the private key you pass it when pushing.
To start go to Start -> Programs -> TortoiseGit -> **PuTTYGen**
On the right hand side, click Generate and wiggle your mouse around under the status bar to generate the two keys. Once done, don't close the window!
Head to Github, log in and then click account settings and [SSH Keys](https://github.com/settings/ssh) on the left. Click the **Add SSH Key**. Give the SSH key a name (i.e. the name of your computer) and then paste the big long key that the puttygen generated. (The 'Public key for pasting into OpenSSH authorized\_keys file:)
Once pasted in, hit **save**.
Head back to PuttyGen. You need to save the private key and feed it into TortoiseGit.You do this by entering a passphase if you want (makes it more secure), then clicking '**Save Private Key**'. Make sure you choose a good location, as you'll need this every time you want to make a new repository for Github. Save it as **key.ppk**
Close PuTTYGen and head to the folder where your repository is going to be.
## Creating the Repository (Repeat for each repository)
Navigate to a folder where you want the repository to reside. I'm all about neatness and want to keep all my repositories in one place, so have chosen `C:\Users\mike\xampp\htdocs` (The XAMPP location). That way I can run any PHP files that have been pulled. In there make a folder for the repository. It can be called anything but for constancy I'm naming it Foundation.less.
This folder can be _anywhere_ on your machine.
Once inside the folder, right click and select the option **Git Create repository here...**
Click OK on the first box without checking the box and you should then get an alert:
If you have '**show hidden files**' turned on, you'll see a hidden **.git** folder. If you want the folder to stop being a repository, just delete that.
Right click and go to TortoiseGit -> Settings and then click '**Git**' on the left hand side. Fill in your name and your email - these are the credentials that will be used when pushing.
Next, click **Remote** (on the left, branching off of the selected 'Git' option). Fill in the fields as follows:
**Remote:** this is the name of your repository (can be anything)
**URL:** This is the github URL provided at the top of your repository starting 
Click **Add New/Save** and then OK at the bottom.
You should now be faced with the empty folder. Right click go to TortoiseGit and then click Pull (should be near the top). The Remote should be what you called it in the options. After clicking OK you might get a putty security alert, click yes and you can watch the tortoise do some acrobatics.
Once he's done, you should see all your files in the folder, as they appear on Github.
### Editing and Pushing
Once you've finished editing the files, Right click and select '**Git Commit -> "master**"'.  A dialogue box will appear where you fill in what you've changed and you select the files to commit.
Once you've clicked **OK**, you'll get another box showing the progress. Upon completion, click the **Push** button located in the bottom left of the box.
Click **OK** on the following dialogue and this pushes your changes to Github.
**Success!**
If you have any problems, or can suggest any changes to this blog, [tweet me](http://www.twitter.com/mikestreety).
---
title: "PHP for Front-End Devs; The Story"
date: 2012-05-06
updated: 2021-09-19
intro: Recently, a few friends of mine have been asking questions about PHP and want to learn the basics. I am a front-end developer for a web design agency. i.e. I mainly stick to HTML/CSS and have colleagues who do the heavy PHP stuff
permalink: "blog/php-for-front-end-devs-the-story/"
tags:
- Web
- Front-end Development
- PHP
- PHPFED
---
Recently, a few friends of mine have been asking questions about PHP and want to learn the basics. I am a front-end developer for a web design agency. i.e. I mainly stick to HTML/CSS and have colleagues who do the heavy PHP stuff. However, I think its handy for a front end dev to know the basics of PHP, as it speeds up development time and mean, for me, that i don't have to annoy the other guys every time i need a loop or something.
For that reason I am going to write a small series of Blog posts  - <a href="/category/phpfed/">#PHPFED</a>. If you have any suggestions or any questions, [tweet me](http://www.twitter.com/mikestreety).
I am trying to combat the cliched tutorials that are out there and I'm going to try and provide code that is actually useful. I remember looking back for PHP tutorials and finding:
```php
$a = 'Hello World';
echo $a; //Returns 'Hello World'
```
Its all well and good, but it makes you think 'Why do I need that?'. The next step is normally database integration with some sort of complex code.
This series is aimed at beginners, who just want some really simple functions and instructions to make their lives happier, easier and simpler. I am by no means a PHP expert, but I know the basics enough to show someone else the basics.
With this series of tutorials, I assume you know basic HTML, CSS and have at least heard of PHP.
---
title: Points Brighton - The Aftermath
date: 2012-05-09
updated: 2016-04-08
intro: Last night was the second of my mini-conferences, Points Brighton. It featured speakers and keynotes of all different varieties, and the infamous Points Bazaar (the raffle) was, once more, a hit
permalink: "blog/points-brighton-the-aftermath/"
tags:
- Web
- Events
---
Last night was the second of my mini-conferences, Points Brighton. It featured speakers and keynotes of all different varieties, and the infamous Points Bazaar (the raffle) was, once more, a hit. If you want to see how good it looked, the photos can be [found on flickr](https://www.flickr.com/photos/78206174@N02/sets/72157629656132734/).
As it was my event, I'm not really in a position to give an impartial view about it (despite it being a huge success and amazingly brilliant). So instead, i'll leave it to others to review:
- [Good Developer Conferences by Amber Weinberg](http://www.amberweinberg.com/good-developer-conferences/)
- [Points Mean Pixels by Adam Onishi](http://www.onishiweb.co.uk/)
- [Points Brighton - Points mean Pixels by Anthony Killeen](http://mrqwest.co.uk/209)
If you have a blog post of your own - let me know!
All that is left is the thanks yous and the credits - so bear with me.
## Speakers
Firstly, the reason everyone was there. The speakers. The presentations were fantastic, diverse and informative. Perfect really!
- [Amber Weinberg](http://www.amberweinberg.com/) [![](https://luckysoap.com/images/twittericon.gif "Twitter")](http://www.twitter.com/amberweinberg) stepped up first talking about '**Mobile Development**' (she kindly stepped in for the afflicted [Paul Mist](http://www.aislezero.co.uk/) [![](https://luckysoap.com/images/twittericon.gif "Twitter")](http://www.twitter.com/paulmist))
- Next was [James Seymour-Lock](http://simpleasmilk.co.uk) [![](https://luckysoap.com/images/twittericon.gif "Twitter")](http://www.twitter.com/jamesslock) discussing '**How To Achieve Your Clients Goals Through Effective Design**' ([Slides](http://speakerdeck.com/u/jamessl/p/how-to-achieve-your-clients-goals-through-effective-design))
- After, [Krystian Szastok](http://www.bozboz.co.uk), stepped up to the plate to show off his knowledge on '**The Principle Of Factor Sparsity And Seo**' ([Slides](http://prezi.com/doxamiiug8vk/the-principle-of-factor-sparsity-and-seo/))
- and finally finishing off the evening was [David Pomfret](http://simpleasmilk.co.uk) [![](https://luckysoap.com/images/twittericon.gif "Twitter")](http://www.twitter.com/pomennedy) who told us all about '**Making Type Right'** ([Slides](http://speakerdeck.com/u/pomennedy/p/typography-basics-points-brighton))
They all did brilliantly and based on the tweets, were all well recieved.
## Sponsors
The amount of generous people out there is phenomenal and there was no exception when it came to Points. We had books and t-shirts from [No Starch Press](http://nostarch.com/), books from [A Book Apart](http://www.abookapart.com/), t-shirts from [Belong](http://wearyoubelong.com/), several copies of Introducing HTML5 by Remy Sharp and Bruce Lawson, a book on mobile development from [Tipsy & Tumbler](http://www.tipsyandtumbler.co.uk/) and books and t-shirts from [5 Simple Steps](http://www.fivesimplesteps.com/).
We also had some beautiful postcards designed and printed by [Hatched](http://www.hatchedlondon.com/) and [T/OD](http://www.toduk.com/). The alcohol and drinks were provided by [Bozboz](http://www.bozboz.co.uk) and the venue kindly donated by [The Skiff](http://www.theskiff.org/).
Massive thanks to anyone who sponsored the event.
## People Who Made It Happen
As with any event, there are always the unsung heroes. The people who really make the event happen and help ease the pressure.
- [Toby Howarth](http://tobyhowarth.co.uk/) - who designed the beautiful site.
- [Adam Onishi](http://www.onishiweb.co.uk/) - who made Toby's dreams a reality
- [Clive Walker](http://www.cvwdesign.com/) - who helped set up and lock up
- The clickers - who clicked for our wonderful presenters
- The attendees. Without whom, I could not have raised over £300 for [Tia's Trees](http://uk.virginmoneygiving.com/fundraiser-web/fundraiser/showFundraiserProfilePage.action?userUrl=tiastrees). Thank you.
Keep an eye out for the next one!
---
title: "#PHPFED - Includes"
date: 2012-05-10
updated: 2021-09-19
intro: When developing static sites (i.e. sites without any sort of CMS - be it Wordpress, Drupal etc.) the PHP I find the most valuable is the include.
permalink: "blog/phpfed-includes/"
tags:
- Web
- Front-end Development
- PHP
- PHPFED
---
Before you continue - make sure you understand [the story.](/blog/php-for-front-end-devs-the-story "PHP for Front-End Devs: The Story")
When developing static sites (i.e. sites without any sort of CMS - be it Wordpress, Drupal etc.) the PHP I find the most valuable  is the _include_.
This allows you to include one file into another file. The file that you include can be anything, from txt to HTML. However, generally for constancy the most popular file type is PHP.
To do an include:
- Make sure the file you are working on is saved as .php extension
- Make sure the file you are going to include is saved
- Use the following code:
```php
<?php
include('path/to/file');
```
The include path needs to be relative. normal convention is to store the includes in a folder called 'includes' in the root.
At first you might wonder what this is useful for? The main use would be to include the header, or the footer, of a website. This enables you to change 1 file and it update on all your pages, without having to do a mass find and replace.
You can also use it to help divide up a page - for example if you had a one page website with 5 sections, you could put each of those sections in its own include to help the one page becoming a big mess.
---
title: "#PHPFED - Variables"
date: 2012-05-18
updated: 2021-09-19
intro: Before you continue - make sure you understand the story. The next thing is that php lines always need to end with a semi-colon (;). This tells php that the line ...
permalink: "blog/phpfed-variables/"
tags:
- Web
- Front-end Development
- PHP
- PHPFED
---
Before you continue - make sure you understand [the story.](/blog/php-for-front-end-devs-the-story "PHP for Front-End Devs: The Story")
The next thing is that php lines always need to end with a semi-colon (;). This tells php that the line has finished and to run it. Without this you will experience 'Unexpected' errors.
So lets get started. In a line - Variables let you store data, or a value, in a word.
e.g.
```php
$m = 'mikestreety';
```
You use this variable, you need to echo, or print out, the result. The are two basic ways to achieve this. You can do it the classic way:
```php
<?php echo $m; ?>
```
Admittedly, this is a poor example of why you would use a variable, after all, why store a single word?
That is because variables are a lot more powerful than this, they can stores lists, they can help you connect to a database, loop through things, if statements - the list goes on. Variables are the very base of PHP and without them, PHP would be impossible.
So, lets look a practical example of a variable.
Say you have a link you regularly update on a homepage, but this link is in 4 different places. Rather than find and replace, or hunt around for them, you could declare them as a variable at the top, then use that throughout the document.
```php
<?php $link = "http://mikestreety.co.uk"; ?>
<a href="<?php echo $link; ?>">My Website</a>
```
Variables can, on the simple level, store strings and numbers. A string is a piece of text and is put in either speech marks or inverted commas to mark the start and the end. (see the previous examples). With a string, you may find that it features an inverted comma, or a speech mark which is ending your string early, and then throwing an error. This can be avoided by whats known as escaping the character. The escape character immediately proceeds the troublesome character, to tell php to take it as a literal punctuation.
That's it for the very basics of the variable. It may seem a little odd on its own, but i'll be covering more things it can do. Once you've understood the variable and that it can store things, PHP is wide open
---
title: Points
date: 2013-05-13
updated: 2016-04-08
intro: This week I announced that I was closing the curtain on my mini-conference Points Brighton. Points has been my baby, my creation. I feel, now it has found its end.
permalink: "blog/points/"
tags:
- Web
- Events
---
This week I announced that I was closing the curtain on my mini-conference [Points Brighton](http://www.pointsbrighton.co.uk/).
Points has been my baby, my creation. I feel, now it has found its end, I would like educate you in where it started, why it started and how it started in the hope that you feel inspired. In the hope you can take these words and transform them into something of your own making.
### Insites: the tour
It all started when I attended the [Insites Tour](http://viewportindustries.com/events/insites-the-tour/) back in 2011. It was an evening event getting to know people within our web industry and where they came from. It was a great event which was my first 'proper' web event. I met some great people there and it soon got my cogs turning.
The unique thing about Insites, and why I could attend, was because it was an evening event. It was also reasonably priced.
From there, I started thinking - why aren't there more evening web events?
### Advice & Help
The advice you can get from anyone in the web is phenomenal. Everyone is willing to help, everyone will answer. I emailed the organisers of Insites and the people they interviewed for advice in setting up my event. I wanted a cheap, evening event that would put off no-one. One where rising stars could hone their speaking skills, one where people don't have to justify to their boss about why they should have a day off, or why they should pay for one of their employees should not be at work.
From here, I started looking at venues and asking for help. Its amazing who puts their hands off.
### The First Points
The first Points took place back in 2011. Wanting to keep the price down, I made it a free event. Within a few days I had sold all the tickets. That was 50 people wanting to come to an event _I_ was putting on. That was a rush I will never forget.
It was awesome, I and everyone else had a great time. The second and third Points came so easily after that, most of it planning itself!
### From There
From that first event, I have learnt a lot, a have grown as a developer, and as an organiser. Everyone should give it a go and whether you think it goes well or not, people will have a good time. Points gave me my first [magazine article](/blog/start-your-own-event/) and has given me some new friends.
So go on, go and put on an event!
---
title: PHP Classes - Explained
date: 2014-12-03
updated: 2021-09-19
intro: To put it very simply, a PHP class is a way of grouping a set of functions and variables into entities,allowing them to be used as self-contained instances.
permalink: "blog/php-classes-explained/"
tags:
- Web
- PHP
- Back-end Development
---
To put it very simply, a PHP class is a way of grouping a set of functions and variables into entities,allowing them to be used as self-contained instances. It is often described as the "cookie cutter". They are the groundwork behind object oriented programming.
Once a class is in use (once it has been in **"instantiated"**) then this creates an **object** (the "cookie").
Functions inside of classes are called **methods** and variables are called **properties**
### Creating a Class
Creating a class couldn't be simpler. For this article I will be using the analogy of a bike - as we are all familiar with bikes and how they work. The bike I currently own is a _Jamis Ventura_ - this will all become clear later.
To create a class, define it using the `class` keyword:
```php
class Bike
{
}
```
The groundwork of the class is now complete! However classes on their own don't do anything, they need to be instantiated. We do this using the new keyword, and store it in a variable.
```php
$jamis = new Bike;
```
The variable `$jamis` is now an instance of the `Bike` class. Because the class has no methods or properties, inspecting the output of a `var_dump` returns the following:
object(Bike)
### Add a property
Bikes have 2 wheels - which we want to add as a property to our class.
Properties & Methods in a class can either be **public** (can be accessed outside of the class) or **private** (can only be referred to by other properties and methods inside the class). There is also **static** and **protected**, but they are a little beyond the scope of this article.
For this example, we will define a public property, for ease of reading and writing a value to this property.
```php/2
class Bike
{
public $numberOfWheels = 2;
}
```
Now we can echo the `numberOfWheels` property on our `$jamis` Bike object
```php
$jamis = new Bike;
echo $jamis->numberOfWheels;
```
This outputs _"2"_
### Add a method
A method (function) gives the ability to be a bit more complex and return more than just a string. For now, we just want to return a simple sentence.
This is achieved by declaring the function with a return:
```php/4-7
class Bike
{
public $numberOfWheels = 2;
public function whatIs()
{
return 'I am a mode of transport with 2 wheels';
}
}
```
I can now echo `$jamis->whatIs();` and have that phrase output on the screen.
### Using properties and methods within the class
This method, however, currently is not doing it much. We could just have easily stored this sentence in a variable.
We can update the method to utilise properties in the class to construct a more dynamic sentence.
```php
public function whatIs()
{
return 'I am a mode of transport with ' . $this->numberOfWheels . ' wheels';
}
```
### Updating properties
Once a class is instantiated, you can change the value of properties.
I've added a `$model` property to my class:
```php
class Bike
{
public $numberOfWheels = 2;
public $model = 'Ventura';
public function whatIs()
{
return 'I am a mode of transport with ' . $this->numberOfWheels . ' wheels';
}
}
```
If for this instance I wanted to change the model, I can simply change the value of the property, using the new instantiated object.
```php
$jamis = new Bike;
$jamis->model = 'Icon';
echo $jamis->model;
```
This will output 'Icon'. Properties can also be updated within methods.
### Passing parameters to methods
I've updated my class to allow the bike model to be passed in via a method/parameter:
```php
class Bike
{
public $numberOfWheels = 2;
public $model = 'Ventura';
public function whatIs()
{
return 'I am a mode of transport with ' . $this->numberOfWheels . ' wheels';
}
public function whatModel($model)
{
$this->model = $model;
return 'The model of this bike is: ' . $this->model;
}
}
```
This would then allow me to update the `$model` property and use it at the same time.
```php
echo $jamis->whatModel('Icon');
echo $jamis->model;