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!
Basically bought the book, which clearly states it supports the latest PHP (version 4+) unfortanately the book uses the old syntax for variables and such (basically the guys writes the whole book as if you had registered globals switched on, i dont!)
so all the tutorials ive been following dont work properly until iu switched it on, but i dont want it on, how do i make the variables work without it?
Ideally you'd go through all your code and change it to use the superglobal arrays. For example, any vars passed through the URL would be accessed as $_GET['var'] instead of $var, and any vars passed through a POST method form would be $_POST['var'] instead of $var, and so on.
This can be quite time-consuming though, and if you want your site to work while you're in the process of updating your code to match current methods, you could include these lines at the top of all your PHP files.
well tbh i think its lame, i bought the book so i could start learning the advanced things like arrays and such and now even the simple tutorials that go a little more in-depth than ive been before wont work
any chance someone could give me a snippet of example code so i know what to change?
but i tried that earlier actually, first thing i thought of, always worked for me before with advanced passing of variables, weirdly enough it never worked for me
maybe its just me, syntax was probably <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> somewhere
@malcolmboston,
I agree that it's rather annoying that you buy a 'new' book, but it isn't up-to-date in it's content. Thats just a negative side effect of using open source applications, something that we all need to live with.
Iv'e seen books that has a papercover telling me that 'Since this book was printed, more functions as X & Y has been added. Referering to page http://... for more info' that gave me a couple of warnings.
Unless I'm creating PHP for my own server which I know has register_globals on and also has safe_mode turned off, I always write the code so that it will work with with register_globals turned off and safe_mode turned on..... that way problems very rarely crop up.
Can't think of a 'quick fix' for you though (sorry)...... sounds like you will have to go through all your code and change it manually.