Follow us on Twitter!
Understanding is the answer, hatred is the problem, and hackers are the slaves abused and destroyed in the process of peace online - Deshouleres
Saturday, April 19, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 24
Guests Online: 23
Members Online: 1

Registered Members: 82832
Newest Member: SerMSYS
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Page 3 of 3 < 1 2 3
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-07-09 01:39
system_meltdown wrote:
Alternatively, create a your own MySQL class.


Or if you don't have time, knowledge or don't feel like it, you can use the MySQLi class instead of making your own.


Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 01:57
c4p_sl0ck wrote:
system_meltdown wrote:
Alternatively, create a your own MySQL class.


Or if you don't have time, knowledge or don't feel like it, you can use the MySQLi class instead of making your own.


Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

p4plus2
Member

Your avatar

Posts: 167
Location:
Joined: 31.03.08
Rank:
Newbie
Posted on 25-07-09 02:18
system_meltdown wrote:

Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.


I agree with you for the most part, however if you are after speed use MySQLi. Writing your own class can in some cases be up to three times slower than procedural programming styles. Classes still become useful when it comes to flexibility, code organization, and reusability.

For anybody that wants a decent comparison of OOP and procedural programming check out this link.
http://devzone.zend.com/article/1236



"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 10:47
p4plus2 wrote:
system_meltdown wrote:

Yeah that's a good point, only reason I suggested creating your own is it will benefit with learning concepts of OOP.


I agree with you for the most part, however if you are after speed use MySQLi. Writing your own class can in some cases be up to three times slower than procedural programming styles. Classes still become useful when it comes to flexibility, code organization, and reusability.

For anybody that wants a decent comparison of OOP and procedural programming check out this link.
http://devzone.zend.com/article/1236


Agreed, over-use of OOP when it's not needed just uses up resources. However I'm guessing since this guy seems pretty new to PHP, he won't care for code optimization, so writing his own class would be fine (if he thinks he can do it at least), else, go with MySQLi, it's pretty slick.


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 25-07-09 10:53
system_meltdown wrote:
Agreed, over-use of OOP when it's not needed just uses up resources. However I'm guessing since this guy seems pretty new to PHP, he won't care for code optimization, so writing his own class would be fine (if he thinks he can do it at least), else, go with MySQLi, it's pretty slick.


nice discussion there =D that's why I like asking questions instead of googling =D=D

The time / knowledge is not the issue here, I can spend a couple hours learning more about php, but to be honest I don't care that much about the optimization or the method itself as long as it gets the job done in the way it's suppose to. Although I gotta say that I find OOP overkill for this particular task! A config file would do just fine I guess =D





Edited by Demons Halo on 25-07-09 10:56
base_dropper@hotmail.com www.demonshalo.com
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-07-09 16:21
MoshBat wrote:
require_once("config.php");

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.


Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 17:28
c4p_sl0ck wrote:
MoshBat wrote:
require_once("config.php"Wink;

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.


Heh, require_once is like echo and print in the sense that both:

echo "hax";
and
echo( "hax" );

are the same.

So yeah, it's not "correct syntax"; however neglecting the brackets looks nicer in my opinion.


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 18:22
MoshBat wrote:
Once again, it's a personal choice thing.


Yep, I don't like using too many brackets and braces, and I like to tab and space everything, makes it easier to read in my opinion.


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

spyware
Member



Posts: 4192
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 25-07-09 18:45
MoshBat wrote:
which saves on mere bytes


You should compare compiled/processed code.



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
[/s
http://bitsofspy.net
Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 20:54
MoshBat wrote:
system_meltdown wrote:
MoshBat wrote:
Once again, it's a personal choice thing.


Yep, I don't like using too many brackets and braces, and I like to tab and space everything, makes it easier to read in my opinion.

I like brackets, I like having everything compressed, such as
Code
if($var == $lul){
   print "Niiice";
}else{
   print "Awwh, fuck";
}



which saves on mere bytes, and --to me-- just looks neater and more uniformed.
But I do, of course, indent appropriately.


echo is better to use than print :p

I dislike using: if( $blah == $blah ){

I find it makes the braces harder to match up, so much easier with them on a separate line :p


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php

p4plus2
Member

Your avatar

Posts: 167
Location:
Joined: 31.03.08
Rank:
Newbie
Posted on 25-07-09 21:06
My personal style is adapted from the coding guidelines for the linux kernel.

Code

<?php

function syntax()
{

        $tab_width = 8;
        $reason = 'legibility and lines stand out'

        if($tab_width == 8){
                echo $reason;
                echo 'Line should also be kept under 80 characters when possible, however
                        I do tend to violate this rule on occasion.';
        }else{
                die('invalid tab width');
        }
}

?>





function braces get there own lines, conditionals do not. It helps me determine what brace you are editing a bit faster IMO. In the linux kernel they tend to use no braces when possible, but I don't do this in php.


"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 25-07-09 21:39
MoshBat wrote:
Also, milliseconds don't matter to me in terms on print/echo.
We've been over this.
I probably use print because of my use of Perl.


It's not just that. Due to echo's nature, it can be overloaded, so instead you can use

Code
echo "Hello, ", $_SESSION['username'], ", how are you?";




Which is a shit lot faster than concatenating with dots, something you cannot do with print.

Plus, if you like to save precious bytes, you should use echo as it's one char less than print :p


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-07-09 06:12
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
require_once("config.php");

Always a good decision.


Not that it really matters, but the correct syntax is:
require_once "config.php";

However both work just fine.

http://us3.php.ne. . .e-once.php
Nice try.
It's the other way round.
Most functions are intended to have brackets around them.
Quick demonstrative example:
Code
require_once($Fuck);
require_once $fuck;




Actually, it's not. As you are referred to on the require_once page:
http://us3.php.ne. . .e-once.php
There they have this example:
Code
<?php
include_once "a.php"; // this will include a.php
include_once "A.php"; // this will include a.php again! (PHP 4 only)
?>






Author

RE: mysql/php

p4plus2
Member

Your avatar

Posts: 167
Location:
Joined: 31.03.08
Rank:
Newbie
Posted on 26-07-09 06:56
c4p_sl0ck wrote:
Actually, it's not. As you are referred to on the require_once page:
http://us3.php.ne. . .e-once.php
There they have this example:
Code
<?php
include_once "a.php"; // this will include a.php
include_once "A.php"; // this will include a.php again! (PHP 4 only)
?>






Also watch out for this:
Code
<?php
var_dump(include_once "nonexistant.php"); // this will dump false
var_dump(include_once "nonexistant.php"); // this will dump true
?>





This happens because php thinks the file was already included, but as we know that is not the case. Not that this should really ever happen in the real world but I figured its worth pointing out.


"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera

"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
p4plus2@hotmail.com
Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-07-09 10:29
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?


Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-07-09 16:51
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?

Oh, nevermind.


Thats right. Give up mosh, just give up. Pfft


Author

RE: mysql/php


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-07-09 21:56
MoshBat wrote:
S1L3NTKn1GhT wrote:
MoshBat wrote:
c4p_sl0ck wrote:
MoshBat wrote:
Guys...
Whomever missed my point above, example #2 of require_once, without brackets doesn't work, at least, not on my version of PHP.
And you use require_once() so the same file *doesn't* get included twice...


I think there's some misunderstanding in this thread. What is it that's not working?

Oh, nevermind.


Thats right. Give up mosh, just give up. Pfft

Gave up explaining.


Exactly. Wink


Page 3 of 3 < 1 2 3