Forums
May 15, 2024, 01:31 AM

Author Topic: PHP expert needed!  (Read 5315 times)

0 Members and 1 Guest are viewing this topic.

Offline THeDoGG

Re: PHP expert needed!
« Reply #15 on: February 29, 2012, 09:52 PM »
damn where is the smite button ?

Offline Peja

VoK: i have now beer so my rope will be perfect.
 VoK: will do ttrr every map under 30s

Offline philie

Re: PHP expert needed!
« Reply #17 on: February 29, 2012, 10:52 PM »
damn where is the smite button ?

 ;D :D

Offline TheKomodo

Re: PHP expert needed!
« Reply #18 on: March 01, 2012, 07:52 AM »
Lol, I thought this said PCP expert needed...

Offline MonkeyIsland

Re: PHP expert needed!
« Reply #19 on: March 01, 2012, 08:32 AM »
All the best PHP frameworks use the first method or short syntax (<?=$var?>) or some template engine ({%var%}). Second method fails when there are different quotes inside, each of them will require "\". If you still prefer this way, then I would recommend to use heredoc synax.

Interesting statement. Please link me to some of these "best PHP frameworks"?
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. Also there's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

Re: PHP expert needed!
« Reply #20 on: March 01, 2012, 08:56 AM »
Interesting statement. Please link me to some of these "best PHP frameworks"?

Here are some pages from Yii/Symfony/Zend frameworks guides/books where you can see that:

http://symfony.com/doc/current/book/templating.html
http://www.yiiframework.com/doc/guide/1.1/en/form.view
http://www.yiiframework.com/doc/blog/1.1/en/comment.create
http://framework.zend.com/manual/en/learning.quickstart.create-layout.html
http://framework.zend.com/manual/en/zend.view.introduction.html

They all follow the MVC pattern, means separating business logic and view, that's why all view-files look simple and even using <?php ... ?> doesn't make them hard to read.

Here is a link for Ray, maybe he will consider to switch to some framework instead of solving all tasks manually: http://symfony.com/doc/current/book/from_flat_php_to_symfony2.html :) But Symfony 2 looks a bit overcomplicated to me, so I would recommend to take a look at Yii first.

Hope it helps! :)


dt`wreckz: zooks are effected my win

Offline MonkeyIsland

Re: PHP expert needed!
« Reply #21 on: March 01, 2012, 11:12 AM »
First off, using php tags inside html is a matter of taste and the original pattern of coding. Personally I find it extremely ugly not to mention it's cumbersome in many cases. A long html page with tons of variables makes it insanely hard to read, causes a lot of redundant open/close php tags to begin with. I guess PHP isn't the very first language you learned right? It seems like you learned some other language like C before, then "adjusted" PHP knowledge onto it?

Secondly, frameworks! Almost every decent php application is kinda a framework because it would be impossible to manage as it grows. TUS uses a framework but a private one. While using a pubic framework could be a good practice, but it is not a prescription you can write for everyone. You shouldn't suggest a public framework to someone who is in early learning stages. It is like giving a book "how to read fast" to a kid who is learning how to read.

Second method fails when there are different quotes inside, each of them will require "\".

That's not correct. Not each of them, only for the same quote used for defining the string.
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. Also there's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

Re: PHP expert needed!
« Reply #22 on: March 01, 2012, 11:29 AM »
Frameworks are just sets of best web practices, I don't force Ray to start using them right now, but I think every web developer should know OOP, MVC, patterns and other smart words :D

About php tags... I'm kinda surprised you prefer to put everything inside echo, doesn't it make the code unreadable? Also I'm not sure IDEs support syntax highlighting in this case... I agree there cases when it's the prefered way, but usually there are much more HTML code than PHP (if logic and presentation are well separated).


dt`wreckz: zooks are effected my win

Offline Ray

Re: PHP expert needed!
« Reply #23 on: March 02, 2012, 06:44 AM »
Every decent web developer should learn the tool - in this case, the language of PHP - they are working with very thoroughly, maybe then move on to a framework. I am still at the beginning steps of both programming and the PHP language, so I will try and code my own solutions, because that is the best practise.

Offline THeDoGG

Re: PHP expert needed!
« Reply #24 on: March 03, 2012, 01:23 PM »
Best practise, maybe .. But if so you should actually first learn C, then once you master it you should switch to PHP!

We already had this debate before Ray, I was telling that frameworks are a good way to save time and bootstrap projects :) Depends on your purpose, if you consider time as money and you are working for customers then frameworks and libs are just a good way.
If you code for pleasure and if your goal is to master the language, then doing everything from scratch could be something interesting..
But using some framework can also be a nice way to "learn from examples"

You want a calendar ?? You could use this http://jqueryui.com/demos/datepicker/#default
Or maybe you prefer to code it all by yourself :) After all Jquery is just a JS framework, but why using it if you can code it all by yourself !!

I am not web developper, and I do not want to be one, but thanks to RoR I can deliver you a full customized dynamic website within few weeks (~ 1000 / 2000 €)
« Last Edit: March 03, 2012, 01:26 PM by THeDoGG »

Offline Ray

Re: PHP expert needed!
« Reply #25 on: March 07, 2012, 04:44 AM »
If you code by yourself, you have a lot more freedom in what you do, and it's a great practise to be pushing yourself to be better at your job, which in this field is necessary.

It is a very basic accessibility question that you should not use something like JS for a core feature, like this calendar.

Offline Ray

Re: PHP expert needed!
« Reply #26 on: March 11, 2012, 05:11 PM »
Okay you lovely geeks, I could not find an answer for this - most likely due to my bad googleing skills - so help me out:

When appending values to an array and defining keys for it, is it possible to use any built-in functions to define those keys without using temporary variables?

Code: [Select]
while ($Row = mysql_fetch_assoc($Events))
{
$Year = date("Y", $Row['Date']);
$Month = date("n", $Row['Date']);
$Day = date("j", $Row['Date']);
$Time = date("G:i", $Row['Date']);
$EventList[$Year][$Month][$Day] = array
(
"Time" => $Time,
"City" => $Row['City'],
"Place" => $Row['Place'],
"Website" => $Row['Website']
);
}
mysql_free_result($Events);
unset($Year, $Month, $Day, $Time);

$Events contains a selection from the database and the Date records are formatted in Unix timestamp - yea MonkeyIsland, I am following your advice of keeping data as raw as possible :) - and this way, I need four temporary variables, which I don't like (well, actually only three, $Time is not necessary).

So is there any way to define these like this:

Code: [Select]
$EventList[date("Y", $Row['Date']]...

Offline MonkeyIsland

Re: PHP expert needed!
« Reply #27 on: March 11, 2012, 05:35 PM »
Don't you try before asking? :p

Code: [Select]
while ($Row = mysql_fetch_assoc($Events))
$EventList[date("Y", $Row['Date'])][date("n", $Row['Date'])][date("j", $Row['Date'])] = array(
"Time" => date("G:i", $Row['Date']),
"City" => $Row['City'],
"Place" => $Row['Place'],
"Website" => $Row['Website']
);
mysql_free_result($Events);
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. Also there's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

Offline Ray

Re: PHP expert needed!
« Reply #28 on: March 11, 2012, 05:49 PM »
I did, I just used the wrong syntax apparently. :) Thank you!

Offline Ray

Re: PHP expert needed!
« Reply #29 on: March 29, 2012, 01:58 PM »
Hey, here's an odd question:

As this website I'm finishing offers the same document in multiple languages - English and Hungarian - it's a good practise to have the alternative documents tagged in the <head> part, and I would like to do this, as Google apparently does not index the Hungarian version of the website.

That is because - as MonkeyIsland does here - I use separate english.php and hungarian.php files that contain the exact same array, filled with the English and Hungarian versions of the website's content. When the user selects language, the selection is stored in a session variable and php includes the selected php file with the array.

But... as this is a user interaction, search engines are unable to crawl that deep. So the question is: is it possible to tag an alternative version in the <head> section this way?

I was thinking of using the get method to send the language selector form's data to the server, which sounds the most sensible solution.

Code: [Select]
<link rel="alternate" hreflang="hu" href="http://url.com/?lang=hu" />
But the whole point of this method is to completely get rid of such parameters in the url, so maybe this could help?

Code: [Select]
if (isset($_GET['lang']))
    {
    $_SESSION['Language'] = $_GET['lang'];
    unset ($_GET['lang']);
    header ('Location: ' . $document_root . '/' . (isset($_GET['page'])) ? '?page=' . $_GET['page'] : ''))
    }

That way the user input does get stored in the session AND we also get rid of the url. Bare in mind, I only used get method here to be able to send input with a static url.

Any better ideas?