Jump to content

Recommended Posts

Hello All,

 

I'm trying to put a lot of what I do into function calls now to make my code a bit tidier and consise.  Take this simple if statement:

 

if ($_GET['thedate'] =='') {
$var = date('l, jS F, Y',time());
} else {
$var = date('l, jS F, Y', strtotime($_GET['thedate']));
}

 

How could I put this into a function and in some kind of switch statement?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/216493-turn-this-code-into-a-function/
Share on other sites

<?php
function REGURGIDATE() {
if ($_GET['thedate'] =='') {
	return date('l, jS F, Y',time());
} else {
	return date('l, jS F, Y', strtotime($_GET['thedate']));
}
}
echo REGURGIDATE();
?>

Agreed I would combine the two codes so that the function getDate() became REGURGIDATE(). I would use ignace's code it is shorter and more precise. However Pikachu2000's code will work aswell.

Thanks,

Colton Wagner

@Pikachu2K, You made me laugh

@ignace, yes I thought English was your native language, but now in my mind when I read your posts, your voice sounds like Stevie Hawkins

 

@Mr Chris, Did you even try to use a switch statement in a function before posting?

Of course you can use switch in a function.

 

Q. Are you the same Mr Chris from sheffieldforum.co.uk?

@ignace, yes I thought English was your native language, but now in my mind when I read your posts, your voice sounds like Stevie Hawkins

 

At least my English teacher can be rest assured that she did a good job on the writing part :) Not sure how Stevie Hawkins sounds but I'm not that old :)

Sorry Steven Hawkings...

 

http://www.youtube.com/watch?v=HZkyRl5IreM

 

@ignace, yes I thought English was your native language, but now in my mind when I read your posts, your voice sounds like Stevie Hawkins

 

Isn't it annoying for you to always have to speak through my voice?

Thing is I hear Dutch a lot of the time because i'm a keen Blender user and the majority of tutorials are by Dutch peeps (since it's primary developer base and institute is there).

 

I always imagine / copy voices of people, it the animator in me.

 

... On another note, Steven Hawkings voice could be updated to be a lot more natural, but he prefers it because it is now a part of him...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.