PHP variable conversions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
NightPaka
Forum Newbie
Posts: 4
Joined: Mon Jan 17, 2011 5:24 pm

PHP variable conversions

Post by NightPaka »

Hello,

I'm new PHP programmer that just started to learn. I'm picking up quite well but I would like to ask few questions that bother me. It would be rude of me if I would post few dedicated topics so I will post some off-code questions here in hope someone could answer me.


1:

I understand how variable conversion works.

For example, I want to convert integer variable into string one:

Code: Select all

<?php
 $int = 10;
 $str = (string) $int;
?>
Basically now my "10" is converted to ASCII code, right?

Well I wanted to test that by using following code:

Code: Select all

<?php
 $int = 10;
 $str = (string) $int;
[b]echo $int;[/b]
?>
I was hoping I would get some ASCII code as now $int is converted into string. But all I get is number 10 - the one I assigned $int with in the first place. Am I missing something?


2. I went to PHP website earlier today. And I see this: "PHP 5.3.5 and PHP 5.2.17 are available". I don't understand - first I tought 5.3.5 is like beta for testing but I didn't find out am I right. So, why is there two versions of PHP available for download?

3. This is a bit simple - I'm learning PHP and I got quite a grasp of HTML. I want to learn how to make effective dynamic websites. What language should I go with next after PHP? CSS? Maybe go a bit on Javascript?


Thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP variable conversions

Post by requinix »

1. No, it converts the number 10 to the string "10". If you want ASCII characters then you need a function.

2. There are two branches of PHP: the main 5.3 branch and the older 5.2 branch. 5.3 is the "current" version of PHP: it's what you should be developing on if you start something new. However it has functionality and behavior that differs from 5.2 (and from 5.1, 5.0, 4.4...) so people who already have PHP applications from pre-5.3.0 can't use it. But there are still important things like bug fixes that need to be released, so the PHP team supports both branches.
Up until not that long ago there was a 4.4 branch too, which was vastly different from 5.x. But it was so old that they formally discontinued it; the code is still available but the PHP team does not support it (not even for bug fixes). In a few years 5.2 will be discontinued as well, and by then PHP 6 (whatever it turns out to be) will probably have been released, and thus there will still be two branches: the previous "people are still using it so we still need to support it" version and the current "if you're starting something new then this is the branch to choose" version.

3. HTML and CSS go hand-in-hand. You need both to make a website. JavaScript is an enhancement, so you can get away with not using it (though that's a bad idea nowadays). SQL is also something you'll need to learn, but is something you can learn as you go.
User avatar
NightPaka
Forum Newbie
Posts: 4
Joined: Mon Jan 17, 2011 5:24 pm

Re: PHP variable conversions

Post by NightPaka »

Thanks.
Post Reply