Some questions on php

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
jtman
Forum Newbie
Posts: 2
Joined: Thu Jul 21, 2011 2:57 am

Some questions on php

Post by jtman »

Hi, I'm new in php, came across piece of code which I leaves me scratching my head:

Code: Select all

$dbi->query($sql_line)
A number of questions here:
1) What is the "->" operator? I can't find any reference to it except that it is used in Perl.
2) Is this statement querying the database? Why not use the standard php statements for querying the database?

My apologizes if my questions sounds basic. Thanks in advance for the help!
Last edited by Benjamin on Mon Jul 25, 2011 1:29 pm, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
Corvin
Forum Commoner
Posts: 49
Joined: Sun Dec 03, 2006 1:04 pm

Re: Some questions on php

Post by Corvin »

1) It's the arrow operator. You use it to access methods and properties of a class.
2) Yes, it seems that a database class is used to simplify database interaction.

:arrow: http://www.php.net/manual/en/language.oop5.php
jtman
Forum Newbie
Posts: 2
Joined: Thu Jul 21, 2011 2:57 am

Re: Some questions on php

Post by jtman »

Thank you for your help!
Encountered another though,

Code: Select all

<?php
$myfiles=array("test.sql");

foreach ($myfiles as $file) {
	$sql=file_get_contents($file);
		
	$sql_line_m="C";
	print(strcmp($sql,$sql_line_m));
	print("\n".strcmp($sql_line_m,$sql));
	
}
?>
The contents of the test.sql file is just "C".
But the output is:
1
-1

Shouldn't it be 0, equal?
Last edited by Benjamin on Mon Jul 25, 2011 1:30 pm, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
Corvin
Forum Commoner
Posts: 49
Joined: Sun Dec 03, 2006 1:04 pm

Re: Some questions on php

Post by Corvin »

The contents of the test.sql file is just "C".
Maybe it's "C ".
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Some questions on php

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply