PHP - Doubt
whats the diff between echo,print,print_r
what's the difference between include(),require,require_once Similar TutorialsFriends, suppose iam copying 1 to 100 files using a loop in php & when the copy process reach at 50th file my browser went offline. My doubt is will it copy all 100 files ?? OR it will terminate at 50th file ? if i want to get all files copied if the browser went offline then what i want to do ?? Please clear I am trying to run tests on my pages and see how much time each one of em take to execute. For this purpose, i'm using this code which i got online: Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> microtime() returns microseconds & secs since Unix epoch. So after exploding, why do we add them both? Cant we just use the microseconds part? I've tried this code & the one above & both return same time(almost). Code: [Select] <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $starttime = $mtime; ?> <!-- Rest of the php and validation and form elements --> <?php $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds"; ?> Hi all, Can anyone offer assistance with the following: I am trying to obtain a score from a users radio button selection on a simple quiz. i am not able to obtain the results.... Hi All, being a noob when it comes to any sort of coding I am facing a strong learning curve but I'm getting there. With the implementation of our new client portal, we require a new client sign-up api...The following was provided... <?php ////////////////////////////////////////////////////// // THIS CODE IS PROVIDED AS AN EXAMPLE OF HOW TO // USE THE DITTO PORTAL FOR AHSAY API'S. ////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // SET API VARIABLES ///////////////////////////////////////////////////////////////// //SET CUSTOMER ID AND API KEY $customerID = '8000003'; $key = '6NbTmZw5LZdtTO8FuYH9G'; //IF POSTBACK if ($_SERVER['REQUEST_METHOD'] == 'POST') { ///////////////////////////////////////////////////////////////// // GET VALUES FROM FORM ///////////////////////////////////////////////////////////////// $company = $_REQUEST['company']; $address1 = $_REQUEST['address1']; $address2 = $_REQUEST['address2']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $postal = $_REQUEST['postal']; $country = $_REQUEST['country']; $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $type = $_REQUEST['type']; $username = $_REQUEST['username']; $alias = $_REQUEST['alias']; $language = $_REQUEST['language']; $timezone = $_REQUEST['timezone']; ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { if ($country == $c->countryID) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\" selected>".$c->countryName.""; } else { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { if ($language == $l->languageID) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\" selected>".$l->languageName.""; } else { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { if ($timezone == $t->timezoneID) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\" selected>".$t->timezoneName.""; } else { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ///////////////////////////////////////////////////////////////// // BEFORE CALLING THE ADDCLIENT API, YOU SHOULD VALIDATE THE // USER'S INPUT (ALL REQUIRED FIELDS COMPLETE, EMAIL ADDRESS // ETC. ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// // INVOKE ADD CLIENT API TO ACTIVATE ACCOUNT ///////////////////////////////////////////////////////////////// //SET ACCOUNT TYPE AND TRIAL LENGTH $account = 'TRIAL'; $length = '14'; //BUILD URL FOR API CALL $function = 'AddClient'; $url = 'https://api.web-portal.co/?'. "customerID=".$customerID. "&key=".$key. "&function=".$function. "&company=".$company. "&address1=".$address1. "&address2=".$address2. "&city=".$city. "&state=".$state. "&postal=".$postal. "&country=".$country. "&firstname=".$firstname. "&lastname=".$lastname. "&phone=".$phone. "&email=".$email. "&type=".$type. "&username=".$username. "&alias=".$alias. "&language=".$language. "&timezone=".$timezone. "&account=".$account. "&length=".$length; //MAKE API CALL USING SIMPLE XML $createClient = simplexml_load_file($url); //DISPLAY RESULTS OF API CALL echo $createClient; } //NOT POSTBACK else { ///////////////////////////////////////////////////////////////// // INVOKE LIST COUNTRIES API TO POPULATE COUNTRY DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListCountries'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListCountries'; //MAKE API CALL USING SIMPLE XML $countrylist = simplexml_load_file($url); foreach ($countrylist as $c) { $countryOptions.="<OPTION VALUE=\"".$c->countryID."\">".$c->countryName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST LANGUAGES API TO POPULATE LANGUAGE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListLanguages'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListLanguages'; //MAKE API CALL USING SIMPLE XML $languagelist = simplexml_load_file($url); foreach ($languagelist as $l) { $languageOptions.="<OPTION VALUE=\"".$l->languageID."\">".$l->languageName.""; } ///////////////////////////////////////////////////////////////// // INVOKE LIST TIMEZONES API TO POPULATE TIMEZONE DROP DOWN LIST ///////////////////////////////////////////////////////////////// //BUILD URL FOR API CALL $function = 'ListTimezones'; $url = 'https://api.web-portal.co/?customerID=8000003&key=6NbTmZw5LZdtTO8FuYH9G&function=ListTimezones'; //MAKE API CALL USING SIMPLE XML $timezonelist = simplexml_load_file($url); foreach ($timezonelist as $t) { $timezoneOptions.="<OPTION VALUE=\"".$t->timezoneID."\">".$t->timezoneName.""; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <p>NEW CLIENT SIGN UP</p> <form id="NewClientForm" name="NewClientForm" method="post" action="NewClientForm.php"> <p>Company Name:<br /> <label for="company"></label> <input type="text" name="company" id="company" value="<? echo $company; ?>" /> </p> <p>Address 1:<br /> <label for="address1"></label> <input type="text" name="address1" id="address1" value="<? echo $address1; ?>" /> </p> <p>Address 2:<br /> <label for="address2"></label> <input type="text" name="address2" id="address2" value="<? echo $address2; ?>" /> </p> <p>City:<br /> <label for="city"></label> <input type="text" name="city" id="city" value="<? echo $city; ?>" /> </p> <p>State/Province:<br /> <label for="state"></label> <input type="text" name="state" id="state" value="<? echo $state; ?>" /> </p> <p>Zip/Postal Code:<br /> <label for="postal"></label> <input type="text" name="postal" id="postal" value="<? echo $postal; ?>" /> </p> <p>Country:<br /> <label for="country"></label> <select name="country" id="country"> <? echo $countryOptions; ?> </select> </p> <p>Primary Contact First Name:<br /> <label for="firstname"></label> <input type="text" name="firstname" id="firstname" value="<? echo $firstname; ?>" /> </p> <p>Primary Contact Last Name:<br /> <label for="lastname"></label> <input type="text" name="lastname" id="lastname" value="<? echo $lastname; ?>" /> </p> <p>Primary Contact Telephone:<br /> <label for="phone"></label> <input type="text" name="phone" id="phone" value="<? echo $phone; ?>" /> </p> <p>Primary Contact Email:<br /> <label for="email"></label> <input type="text" name="email" id="email" value="<? echo $email; ?>" /> </p> <p>Account Type:<br /> <input type="radio" name="type" id="acb" value="ACB" /> <label for="acb">ACB</label> <input type="radio" name="type" id="obm" value="OBM" /> <label for="obm">OBM</label> </p> <p>Preferred Username:<br /> <label for="username"></label> <input type="text" name="username" id="username" value="<? echo $username; ?>" /> </p> <p>Alias/Nickname:<br /> <label for="alias"></label> <input type="text" name="alias" id="alias" value="<? echo $alias; ?>" /> </p> <p>Language:<br /> <label for="language"></label> <select name="language" id="language"> <? echo $languageOptions; ?> </select> </p> <p>Timezone:<br /> <label for="timezone"></label> <select name="timezone" id="timezone"> <? echo $timezoneOptions; ?> </select> </p> <p> </p> <p> <input type="submit" name="submit" id="submit" value="Sign Up" /> </p> </form> <p><br /> </p> </body> </html> The following errors are produced... http://cubetech.com.au/downloads/signup.php Can please confirm my suspicions of simplexml_load_file() are not permitted. I have been reading about cURL implementation instead can someone provide some assistance if this is possible and assist. A lot of thank in advance, Andrew Chapman Hello guys, i need to create a code for making connections with SSL servers (particularly SMTPS and POP3S) and i know about the existence of OpenSSL extension. However, i'm in doubt about a basic issue: 1. Is this extension useful for creating SSL clients or SSL servers? I'm not a SSL expert, so maybe i'm misunderstanding something; i hope you can help me. Kind regards. I'm not sure if this is exactly a coding help question, excuse me if its not. I want to know what is the best & secure way to submit a form to itself. I've tried to google the answer, but did not get a proper answer with explanation or may be I didnt use proper keywords to search it. Out of these which one do i use? Code: [Select] // Leave the action field empty. <form method="POST" action=""> //$PHP_SELF, also if i use echo $PHP_SELF my form does not work like it should. <form method="POST" action="<?$PHP_SELF?>"> //$_SERVER['PHP_SELF'], same problem as $PHP_SELF, it doesnt work if i use echo. <form method="POST" action="<?$_SERVER['PHP_SELF']?>"> I have a php code that call a process (a java program). The process runs in background for a so long time - from 1 minute to 2 hours. I make the process call using exec:
<?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " &> /dev/null &"); } } $command = "java ... ReadEmailsCmdLine 2>&1"; execInBackground($command); echo "FINALIZADO";Though the command runs in background it looks that the PHP code wait for the command completion to send a answer to client browser because I just see "FINALIZADO" after the java program finished its execution. Does someone know how I can solve this problem? Or at least does have a hint/pointer for that? Since now I thanks any comment/suggestion |