...

View Full Version : PHP training resources



tdavis
08-26-2009, 01:18 PM
I am looking for recommendations for PHP training. I am an RPG programmer, with a couple of years experience with Perl. I started trying to learn PHP a few months ago, and so I have some basic knowledge. But there is obviously so much more. I see all kinds of tutorials on the web, but wonder if there is any good DVD or computer based training out there, either for purchase or otherwise. Any advice is appreciated!

Phil Jackson
08-26-2009, 01:23 PM
from experience (a long time ago) find a script (any) then play around with it. Look up the functions on php.net and see what happens. Any help you need just post it here and they will be someone to point you in the right direction. Most languages are the same just wrote different.

Phil Jackson
08-26-2009, 01:55 PM
<?php

if(isset($_POST['submit']))
{
if(isset($_GET['time']))
{
$difference = (time()-$_GET['time']);
echo "Time diff in seconds: ".$difference." secs";
}
}

?>

<form method="post" action="index.php?time=<?php echo time(); ?>">
<input type="submit" name="submit" value="submit">
</form>


alter it, see what happens.
list of things to look up:

$_POST[];
$_GET[];
time();
echo
if
isset()

google:
'php - concatenate strings'
'php - difference in " and ' '
'php - variables'

whizard
08-26-2009, 02:30 PM
Where I began my journey:

tizag.com
w3schools.com
PHP for dummies (book), lots of other PHP books

Godspeed!
Dan

Fou-Lu
08-26-2009, 03:49 PM
Where I began my journey:

tizag.com
w3schools.com
PHP for dummies (book), lots of other PHP books

Godspeed!
Dan

I've always been curious if the PHP for dummies book is any good?
I find that books tend to outdate rather fast, and since PHP is probably among the most popular web scripting languages out there (excluding html of course, but thats not really a scripting language), so I recommend just the basic PHP.net site. It has pros and cons.

I assume you have knowledge of C? PHP is very much like C syntactically, though it completely lacks explicit datatypes, function prototyping and pointers. Many of the function names are the same as from C. The API will provide great examples and user notes; however, you must know what it is you're looking for in order to review the answer (ie: you must know that array_merge is the function for merging two arrays, otherwise you won't be able to find it in the site [easily]). On that note, PHP doesn't have arrays either. Arrays are all hashmaps in PHP, and they are not genericable either, so any array takes any data. On the plus, we don't need to resize them.
If you're like me, I'm a kinesthetic learner, so just keep playing with it an you'll learn the language.

whizard
08-26-2009, 04:06 PM
Well, I began learning PHP when I was 12 or 13, so it eased my entry into computer programming. At the time, I had no knowledge of C, but now I have a little. The PHP/dummies book is good if you have no clue what's going on, as the title indicates :)

It had a lot of examples I could look at and play with in the way Phil Jackson suggested.

Bottom Line: I found it helpful, but you quickly move on from it.

Dan

tdavis
08-26-2009, 04:57 PM
I saw a reference to the PHP BLACK BOOK, but it looks like it was written in 2001. has PHP been around that long? I do not have any knowledge of C, but I do of Perl. Below is one PHP script that I wrote recently. You will see that I am using db2_ tools. This is basic. I am trying to understand more complex situations; for example, how to handle web services...



<html>
<head>
<title>Drop Ship - File Request Menu (Inventory Movements File)</title>
</head>
<body>

<?php

ini_set('display_errors','1');
error_reporting (E_ALL);
$error_flag = "";

$process_description = "Process Returns File";

// Parse input //
$siteID = $_GET['site'];
$applicationID = $_GET['app'];
$environmentName = $_GET['envr'];
$vendorCode = $_GET['vendor'];

// Set library list //
$testing_flag = "No";
$owner = $applicationID;
$listname = $environmentName;
require("setlibl_db2.php");

// Open iSeries connection //
$database = 'PREPROD';
$user = 'myusername';
$password = 'mypassword';
$conn = db2_pconnect($database, $user, $password);
if (!$conn) { exit("<br>Connection Failed: " . $conn); }

// Prepare Stored Procedure call /
$proc = 'CALL GET_MOVEMENTS(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
$stmt = db2_prepare($conn, $proc) or die("db2_prepare failed<br>");

// Define output parameters //
$return001 = "";
$return002 = "";
$return003 = "";
$return004 = "";
$return005 = "";
$return006 = "";
$return007 = "";
$return008 = "";
$jobid = "";
$return = "";
$message = "";

// Bind output parameters //
db2_bind_param($stmt, 1, "applicationID", DB2_PARAM_IN);
db2_bind_param($stmt, 2, "environmentName", DB2_PARAM_IN);
db2_bind_param($stmt, 3, "siteID", DB2_PARAM_IN);
db2_bind_param($stmt, 4, "vendorCode", DB2_PARAM_IN);
db2_bind_param($stmt, 5, "return001", DB2_PARAM_OUT);
db2_bind_param($stmt, 6, "return002", DB2_PARAM_OUT);
db2_bind_param($stmt, 7, "return003", DB2_PARAM_OUT);
db2_bind_param($stmt, 8, "return004", DB2_PARAM_OUT);
db2_bind_param($stmt, 9, "return005", DB2_PARAM_OUT);
db2_bind_param($stmt, 10, "return006", DB2_PARAM_OUT);
db2_bind_param($stmt, 11, "return007", DB2_PARAM_OUT);
db2_bind_param($stmt, 12, "return008", DB2_PARAM_OUT);
db2_bind_param($stmt, 13, "jobid", DB2_PARAM_OUT);
db2_bind_param($stmt, 14, "return", DB2_PARAM_OUT);
db2_bind_param($stmt, 15, "message", DB2_PARAM_OUT);

// Execute the stored procedure //
if ($stmt) {
$success = db2_execute($stmt);
if (!$success) {
$db2_error = db2_stmt_error($stmt);
echo "error code: $db2_error<br><br>";
}}

$msga[1] = substr($return001, 00, 50);
$msgb[1] = substr($return001, 50, 50);

$msga[2] = substr($return002, 00, 50);
$msgb[2] = substr($return002, 50, 50);

$msga[3] = substr($return003, 00, 50);
$msgb[3] = substr($return003, 50, 50);

$msga[4] = substr($return004, 00, 50);
$msgb[4] = substr($return004, 50, 50);

$msga[5] = substr($return005, 00, 50);
$msgb[5] = substr($return005, 50, 50);

$msga[6] = substr($return006, 00, 50);
$msgb[6] = substr($return006, 50, 50);

$msga[7] = substr($return007, 00, 50);
$msgb[7] = substr($return007, 50, 50);

$msga[8] = substr($return008, 00, 20);
$msgb[8] = substr($return008, 50, 50);

// Display the results //
print "<img src='images/coxlogo.gif'>";
print "<br><font face='verdana' size='3' color='black'><b>";
print "Process IS1015RA81:<br>$process_description for $vendorCode<br><br>";

print "<table border='1' cellspacing='2' cellpadding='2'>";
print "<tr><td><font face='verdana' size='2' color='black'>Return Code</td><td>$return</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>Return Message</td><td>$message</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[1]</td><td>$msgb[1]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[2]</td><td>$msgb[2]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[3]</td><td>$msgb[3]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[4]</td><td>$msgb[4]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[5]</td><td>$msgb[5]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[6]</td><td>$msgb[6]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[7]</td><td>$msgb[7]</td></tr>";
print "<tr><td><font face='verdana' size='2' color='black'>$msga[8]</td><td>$msgb[8]</td></tr>";
print "</table>";

print "<form method='get' action='ctdi.php'>";
print "<input type='submit' value='Return to Menu'>";
print "</form>";

?>

tdavis
08-26-2009, 05:24 PM
I am new to PHP and web services, so this may be a simple nothing to some of you, but I would really appreciate the help. What am I doing wrong in this script?



<?php
ini_set('display_errors','1');
error_reporting (E_ALL);

$GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");

$account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
$username_r = $GetUserName->username($account); <= line 11
$userId_r = $GetUserName->userId($account);

echo "<br>Account: $account";
echo "<br>User Name: $username_r";
echo "<br>User ID: $userId_r";

?>


Here is the message:

Fatal error: Uncaught SoapFault exception: [Client] Function ("username") is not a valid method for this service in /www/zendcore/htdocs/cox/GetAccountInfo.php:11 Stack trace: #0 [internal function]: SoapClient->__call('username', Array) #1 /www/zendcore/htdocs/cox/GetAccountInfo.php(11): SoapClient->username(Array) #2 {main} thrown in /www/zendcore/htdocs/cox/GetAccountInfo.php on line 11

tdavis
08-26-2009, 06:17 PM
Sorry. Meant to put this as a new thread...

it career
08-27-2009, 11:12 AM
I am new to PHP and web services, so this may be a simple nothing to some of you, but I would really appreciate the help. What am I doing wrong in this script?



<?php
ini_set('display_errors','1');
error_reporting (E_ALL);

$GetUserName = new SoapClient("http://idm.east.dev.cox.net/idmwebservices/CoxIdentityServices?wsdl");

$account = array("GetAllAccountInfoAcctNbr" => "6111027582601");
$username_r = $GetUserName->username($account); <= line 11
$userId_r = $GetUserName->userId($account);

echo "<br>Account: $account";
echo "<br>User Name: $username_r";
echo "<br>User ID: $userId_r";

?>


Here is the message:

Fatal error: Uncaught SoapFault exception: [Client] Function ("username") is not a valid method for this service in /www/zendcore/htdocs/cox/GetAccountInfo.php:11 Stack trace: #0 [internal function]: SoapClient->__call('username', Array) #1 /www/zendcore/htdocs/cox/GetAccountInfo.php(11): SoapClient->username(Array) #2 {main} thrown in /www/zendcore/htdocs/cox/GetAccountInfo.php on line 11

May be it is an authentication problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum