tag:blogger.com,1999:blog-34264815334683041802024-02-06T19:29:32.196-08:00phponlinetutorialUnknownnoreply@blogger.comBlogger186125tag:blogger.com,1999:blog-3426481533468304180.post-48278125779756254922021-06-29T03:57:00.005-07:002021-06-29T03:57:54.297-07:00how to show all the collections mongodb<p><b>Show all the collections mongodb </b></p><p><b>Syntax 1: </b></p><p>db.getCollectionNames()</p><p>Syntax 2: </p><p>show collections</p><p><br /></p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-31692011970086364072021-06-29T03:55:00.000-07:002021-06-29T03:55:06.216-07:00how to delete the collection in mongodb<p><b> Delete the collection in mongodb: </b></p><p>Syntex:</p><p>use database;</p><p>db.collectionName.drop(); this commend delete the collection in mongodb. </p><p>Example: </p><p>db.products.drop();</p><p><b><br /></b></p><p><b><br /></b></p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-81639744395912475002021-06-17T07:45:00.001-07:002021-06-17T07:45:23.696-07:00insert document in collection mongodb<h2 style="text-align: left;"> Insert document in collection</h2><p style="text-align: left;">Two types of insert</p><p></p><ol style="text-align: left;"><li>Insert single records: </li><li>Insert multiple records</li></ol><p></p><p><b>Insert single records: </b></p><p>syntax: </p><p>db.collection.insertOne(</p><p> <document>,</p><p> {</p><p> writeConcern: <document></p><p> }</p><p>)</p><p><b>Example 1: </b></p><p>db.users.insertOne({"name":"ram","email":"ram@gmail.com"}) </p><p><b>Example 2: </b></p><p><span style="white-space: pre;"> </span>db.users.insertOne(</p><p><span style="white-space: pre;"> </span>[{"employee":{"name":"ram","email":"ram@gmail.com"}}]</p><p><span style="white-space: pre;"> </span>)</p><div><div><br /></div><div><b>Insert multiple records: </b></div><div><b><br /></b></div><div><b>syntax</b>:</div><div><br /></div><div>db.Collection_name.insertMany(</div><div><br /></div><div>[<document 1>, <document 2>, …],</div><div><br /></div><div>{</div><div> writeConcern: <document>,</div><div> ordered: <boolean></div><div><br /></div><div>})</div><div><br /></div><div><b>Example: </b></div><div>db.users.insertMany([{"name":"ram","email":"ram@gmail.com"},{"name":"raju","email":"raju@gmail.com"}])</div><div><br /></div></div>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-1310140005387583162021-06-17T02:12:00.011-07:002021-06-18T08:48:04.337-07:00Collection Shell Commands in MongoDB <h2 style="text-align: left;">Create Collection</h2><p><b> Syntax: </b>db.createCollection("Collection Name");</p><p>Example: db.createCollection("users");</p><p><b>Delete collection in Mongodb Shell Command</b></p><p>db.collection.drop() </p><p><b>Find Collection in Mongodb Shell Command</b></p><p>db.collection.find()</p><p><b>Show all Collection in Mongodb Shell Command</b></p><p>show collections</p><p><b>Creat Collection in Mongodb Shell Command</b></p><p>db.createCollection("users")</p><p><b>Rename the Collection In Mongodb Shell Command</b></p><p>db.collection.renameCollection() </p><p><b>Update the single document in MongoDB collections Shell Command</b></p><p>db.collection.updateOne() </p><p><b>Updates all the documents in MongoDB collections that match the given query. </b></p><p>db.collection.updateMany()</p><p><b>Replaces the first matching document in MongoDB collection</b></p><p>db.collection.replaceOne() </p><p><b>Deletes the first document in Mongodb collection</b></p><p>db.collection.deleteOne() </p><p>db.collection.deleteMany()</p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-15292734485056569292021-06-17T02:07:00.005-07:002021-06-18T08:08:05.911-07:00Create Show and Delete Database in MongoDB <p> </p><p><br /></p><p><b>Create Database Shell Command</b></p><p><b>Syntax: </b>use databaseName</p><p>Example: use newproject </p><p><b>Description:</b> <i>"use database"</i> syntax to create the database in MongoDB. if database exists switch to that database.</p><p><b>Show Databases Shell Command</b></p><p>show dbs</p><p><b>Delete Database Shell Command</b></p><p>db.dropDatabase() </p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-35323328661838733362015-06-28T11:36:00.001-07:002015-06-28T11:36:54.233-07:00PHP7.0 Features <div dir="ltr" style="text-align: left;" trbidi="on">
<b>Amazing features of php7 versions </b><br />
<b><br /></b>
<b>1. Increase the performance.</b><br />
<b>2. Standalone Multi-threading Web Server</b><br />
<b>3.Just in time compilation</b><br />
<b>4. Abstract syntax tree</b><br />
<b> </b><br />
<b><br /></b>
<b><br /></b></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-79477722032161942412015-04-23T10:18:00.001-07:002015-04-23T10:18:22.976-07:00send multiple recipients mail configuration in codeigniter<div dir="ltr" style="text-align: left;" trbidi="on">
in order to send multiple recipients mail configuration in codeigniter<br />
<br />
we can add the changes n config file.<br />
$config[''bcc_batch_mode"]="TRUE";<br />
$config["bcc_batch_size"]="none";</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-85188930127387468512015-01-20T21:34:00.003-08:002015-01-20T21:34:22.276-08:00Sql group by query<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: #e5e5e5; color: #444444; font-family: monospace; font-size: 11px;">$sql = "SELECT *,count(`created_on`) as blogcount FROM `tbl_blog` group by DATE_FORMAT(`created_on`,\'%M %Y\') order by created_on asc";</span></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-24921618299606997202014-09-05T23:04:00.001-07:002014-09-05T23:04:54.297-07:00codeigniter interview questions and answers for 2 year experience<div dir="ltr" style="text-align: left;" trbidi="on">
codeigniter interview questions and answers for 2 year experience<br />
<br />
<br />
1.what is the Codeigniter?<br />
Ans: Codeigniter is open source, webapplication a PHP framework. Codeigniter is loosely based on MVC pattern simple framework in php.<br />
<br />
2.What is the current version of codeigniter?<br />
The lastest version 2.2.0 till 6-05-2014.<br />
<br />
3.what are the features of codeigniter?<br />
Ans:<br />
1. codeigniter is open source, webapplication framework.<br />
2.codeigniter is light weight framework.<br />
3.codeigniter faster than any other farmework.<br />
4.codeigniter search engine friendly urls generator.<br />
5.codeigniter is easy exensible.<br />
<br />
<br />
4. Explain codeigniter file structure.<br />
<br />
Application<br />
-cache<br />
-config<br />
-controllers<br />
-core<br />
-errors<br />
-helpers<br />
-hooks<br />
-languages<br />
-logs<br />
-models-<br />
-thirdparty<br />
-view<br />
system<br />
-core<br />
-database<br />
-fonts<br />
-helpers<br />
-language<br />
-libraries<br />
<br />
what is mvc framework?<br />
<br />
Controller: The controller serves as an intermediary between the model and view.<br />
MOdel: The model represents your data structures.<br />
the model consists of application data and business rules.<br />
<br />
view: the view can be any output representation of data.<br />
<br />
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-42100339668724312192014-08-28T00:26:00.002-07:002014-08-28T00:26:16.340-07:00file_exists not working php file_exits doesn't support remote URLs.<div dir="ltr" style="text-align: left;" trbidi="on">
<b><br /></b>
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="font-size: 14px; line-height: 17.804800033569336px;"><b>file_exists not working php</b></span></span><br />
<span style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 17.804800033569336px;"><b>file_exits doesn't support remote URLs.</b></span><br />
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="background-color: white; font-size: 14px; line-height: 17.804800033569336px;">php file functions:</span></span><br />
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="background-color: white; font-size: 14px; line-height: 17.804800033569336px;"><br /></span></span>
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="background-color: white; font-size: 14px; line-height: 17.804800033569336px;">if php file_exits not working. we can try this one </span></span><br />
<span style="font-family: Arial, Liberation Sans, DejaVu Sans, sans-serif;"><span style="background-color: white; font-size: 14px; line-height: 17.804800033569336px;"><br /></span></span>
<span style="color: blue;">if (fopen($fileexitesnotworking, "r")){</span><br />
<span style="color: blue;">echo "file exits"</span><br />
<span style="color: blue;">}else {</span><br />
<span style="color: blue;">echo "not";</span><br />
<span style="color: blue;">}</span></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-85235320684899770892014-07-18T03:06:00.004-07:002014-07-18T03:06:37.255-07:00how to check if user is login are not in drupal<div dir="ltr" style="text-align: left;" trbidi="on">
how to check if user is login are not in drupal<br />
Ans:<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (user_is_logged_in()) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// Do something.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
are<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>global $user;<br />
if($user->uid!=0){<br />
echo "Logged In";<br />
}<br />
else{<br />
echo "Not logged in";<br />
}<br />
<div>
<br /></div>
</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-59532960783115067642014-07-18T03:06:00.001-07:002014-07-18T03:06:08.432-07:00how to get the user role in drupal<div dir="ltr" style="text-align: left;" trbidi="on">
how to get the user role in drupal<br />
Ans: <?php $GLOBALS['user']->roles; ?></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-61056169695179078642014-07-17T04:35:00.002-07:002014-07-17T04:35:13.581-07:00how to i get the current drupal themes path<div dir="ltr" style="text-align: left;" trbidi="on">
how to i get the current drupal themes path?<br />
<br />
global $theme;<br />
$path = drupal_get_path('theme', $theme);<br />
<br />
// there's also a $theme_path global<br />
<br />
global $theme_path;</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-27435633679300884852014-07-17T04:34:00.001-07:002014-07-17T04:34:10.540-07:00drupal folder structure explained<div dir="ltr" style="text-align: left;" trbidi="on">
drupal folder structure explained<br />
/includes: Drupal api files are include here.<br />
/database<br />
/mysql<br />
/pgsql<br />
/sqlite<br />
/filetransfer<br />
/misc :javascript file and images here.<br />
/farbtastic<br />
/ui<br />
/images<br />
/modules : Drupal core modules here.<br />
/profiles : installation profiles here<br />
/minimal<br />
/standard<br />
/testing<br />
/scripts : shell scripts for developers and administrators here.<br />
/sites : all files that are added by a developer to create a site here.<br />
/all<br />
/modules<br />
/themes<br />
/default<br />
/themes:<br />
<br />
php files:<br />
<br />
authorize.php<br />
cron.php<br />
index.php<br />
install.php<br />
update.php<br />
xmlrpc.php<br />
<br />
htaccess<br />
<br />
text files:<br />
<br />
web<br />
upgrade<br />
robots<br />
readme<br />
maintainers<br />
licenes<br />
install</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-41838664591977862072014-07-03T05:45:00.007-07:002014-07-03T05:46:57.930-07:00php array interview questions and answers in php<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: red;">what is an array?</span><br />
Ans: An array stores multiple values in one single variable<br />
<br />
<br />
<span style="color: red;">how to get the first value of an array in php</span><br />
Ans:current() also works on objects:<br />
<br />
<?php<br />
<br />
echo current((object) array('one', 'two')); // Outputs: one<br />
<br />
?><br />
<br />
And echo reset($arr);<br />
$firstValue = each($array)[1];<br />
<br />
<span style="color: red;">how to get the last value of an array in php</span><br />
<br />
<br />
Ans: echo end($array);<br />
<br />
<br />
<span style="color: red;">3.adding an element in beginning of array</span><br />
Ans:<br />
$queue = array("orange", "banana");<br />
array_unshift($queue, "apple", "raspberry");<br />
<br />
<span style="color: red;">4.Insert "elements" to the end of an array</span><br />
Ans:<br />
<br />
$a=array("red","green");<br />
array_push($a,"blue","yellow");<br />
<br />
<span style="color: red;">5. how to delete the last element of an array in php</span><br />
Ans:<br />
$stack = array("orange", "banana", "apple", "raspberry");<br />
$fruit = array_pop($stack);<br />
<br />
<br />
<span style="color: red;">6. how to delete the first element of an array in php</span><br />
Ans:<br />
$stack = array("orange", "banana", "apple", "raspberry");<br />
$fruit = array_shift($stack);<br />
<br />
<span style="color: red;">7. how to create an array php5</span><br />
<br />
Ans: // as of PHP 5.4<br />
$array = [<br />
"foo" => "bar",<br />
"bar" => "foo",<br />
];<br />
?><br />
<br />
<br />
array_values is Return all the values of an array<br />
array_key_exists is Checks if the given key or index exists in the array<br />
array_search is Searches the array for a given value and returns the corresponding key if successful</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-51814598644200049272014-06-24T01:49:00.001-07:002014-06-24T01:50:01.983-07:00php interview questions and answers for two year experienced<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
php interview questions and answers for two year experienced<br />
<br />
1Q: What is the difference between the functions unlink and unset?<br />
<br />
Ans: unlink() deletes the given file from the file system.<br />
unset() makes a variable undefined.<br />
<br />
2Q: How many ways we can pass the variable through the navigation<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>between the pages?<br />
<br />
Ans: GET, QueryString, POST<br />
<br />
3Q: How can we know the count/number of elements of an array?<br />
<br />
Ans: 2 ways<br />
a) sizeof($urarray) This function is an alias of count()<br />
b) count($urarray)<br />
<br />
4Q: How can we convert the time zones using PHP?<br />
<br />
Ans: date_default_timezone_set('Asia/Tokyo');<br />
<br />
5Q: How many ways can we get the value of current session id?<br />
Ans: session_id() returns the session id for the current session.<br />
<br />
6Q: How can we destroy the session, how can we unset the variable of<br />
a session?<br />
Ans: session_unregister — Unregister a global variable from the current<br />
session<br />
session_unset — Free all session variables.<br />
<br />
7Q: In how many ways we can retrieve the data in the result set of<br />
MySQL using PHP?<br />
<br />
Ans: We can do it by 4 Ways<br />
1. mysql_fetch_row. , 2. mysql_fetch_array , 3. mysql_fetch_object<br />
4. mysql_fetch_assoc<br />
<br />
*8Q: What is the difference between mysql_fetch_object and<br />
mysql_fetch_array?<br />
<br />
Ans:<br />
mysql_fetch_object() is similar to mysql_fetch_array(), with one difference -<br />
an object is returned, instead of an array. Indirectly, that means that<br />
you can only access the data by the field names, and not by their<br />
offsets (numbers are illegal property names).<br />
<br />
<br />
9Q: What is meant by nl2br()?<br />
Ans: Inserts HTML line breaks (<BR />) before all newlines in a string.<br />
<br />
10Q: What is the functionality of the function strstr and stristr?<br />
<br />
Ans: strstr Returns part of string from the first occurrence of needle(sub string that we finding out ) to the end of string.<br />
$email= 'test@gmail.com';<br />
$domain = strstr($email, '@');<br />
echo $domain; // prints @gmail.com<br />
here @ is the needle<br />
stristr is case-insensitive means able not able to diffrenciate between a and A<br />
<br />
11Q: Difference between get and post methods?<br />
Get Method:-<br />
1. Get method is faster then post.<br />
2. Get method is not secure.<br />
3. Get method is transfer the data through url.<br />
4. GET method is restricted to send upto 1024 characters only.<br />
5. GET method can't be used to send images or word documents, to the server.<br />
<br />
Post Method:-<br />
<br />
1. Post method is secure<br />
2. post method is transfer the data through headers.<br />
3. we can transfer unlimited data. ans its a secure.<br />
<br />
12Q: Who is the father of PHP?<br />
<br />
Ans: The father of php is Rasmus Lerdorf<br />
<br />
13Q: what is the difference between $sno and $$sno<br />
<br />
Ans: $name is variable where as $$name is reference variable<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>like $name=sonia and $$name=singh so $sonia value is singh.<br />
<br />
14Q: How can i destroy the cookie?<br />
<br />
Ans: In php manual, you can delete a cookie by setting a expiration date is in the past:<br />
setcookie("key","",time()-3600);<br />
<br />
15Q: Different type of errors in PHP?<br />
<br />
Ans: in PHP there are 4 types of errors.<br />
1. NOTICE<br />
2. WARNING<br />
3. FATAL ERROR<br />
16Q: Difference between include and include_once?<br />
<br />
Ans: include: using this include function the file path include directorys and it's sub directorys.<br />
include_once:<br />
<br />
17Q: Difference between include and require<br />
<br />
Ans: Both include and require used to include a file. but when included file not found<br />
Include send Warning where as Require send Fatal Error .<br />
<br />
18Q: How can we submit a form with out submit button?<br />
<br />
Ans: Java script submit() function is used for submit form without submit button<br />
on click call document.formname.submit()<br />
<br />
19Q: What does a special set of tags <?= and ?> do in PHP?<br />
<br />
Ans: The output is displayed directly to the browser.<br />
<br />
20Q: How do you define a constant?<br />
<br />
Ans: Via define() directive, like define ("MYCONSTANT", 100);<br />
<br />
21Q: How do you pass a variable by value?<br />
<br />
Ans:<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><?php<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> function add_some_extra(&$string)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $string .= 'and something extra.';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$str = 'This is a string, ';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>add_some_extra($str);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo $str; // outputs 'This is a string, and something extra.'<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>?><br />
22Q: How can i display variable with value and datatype?<br />
<br />
Ans: var_dump (); using to display the display variable with value and data type.<br />
<br />
23Q: How can i check whether the variable is set with value or not?<br />
<br />
Ans: isset() function to check where the variable is set are not.<br />
<br />
24Q: How can i remove the variable value?<br />
Ans: If a globalized variable is unset() inside of a function, only the local variable is destroyed.<br />
<br />
25Q: I want to combine two variables together:<br />
Ans: $var1 = 'Welcome to ';<br />
$var2 = 'Zend Technologies';<br />
$var3= $var1.$var2;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>What will work faster? Code sample 1:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$var 3 = $var1.$var2;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Or code sample 2:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$var3 = "$var1$var2";<br />
<br />
26Q: What are the print functions we have in php?<br />
<br />
Ans: echo ;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>print();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var_dump();<br />
27Q: How can i destroy the sessions?<br />
Ans: session_destroy(); function to use destroy the session.<br />
<br />
28Q: Function to move the uploaded file from one location to another location?<br />
Ans: move_uploaded_file<br />
<br />
29Q: How can i find out the IP address of client?<br />
Ans: $_SERVER(REMOTE_ADD);<br />
<br />
30Q: difference between mysql_fetch_row and mysql_fetch_object<br />
Ans: mysql_fetch_row is used to fetch the single row only.<br />
mysql_fetch_object use this function to get all records of the table.<br />
<br />
31Q: How can we create a database using PHP and mysql?<br />
<br />
Ans: "CREATE DATABASE NAME"<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>We can create MySQL database with the use of<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mysql_create_db("Database Name")<br />
<br />
32Q: What is the difference between echo and print statement?<br />
<br />
Ans: echo not returns the any values.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>print returns the values<br />
<br />
33Q: What is the difference between explode and split?<br />
<br />
Ans: split() and explode() both are php function used to explode a string. split() almost was used in older php version and now availble version of php is higher than<br />
<br />
ten and its also support explode().<br />
<br />
34Q: difference between mysql_connect and mysql_pconnect<br />
<br />
Ans: mysql_pconnect()<br />
isd to make a persistent connection to the database which means a SQL link that do not close when the execution of your script ends.<br />
<br />
35Q: what is the syntax of mail function.<br />
<br />
Ans: mail();<br />
<br />
36Q: What is the default port number of web server?<br />
<br />
Ans: 8080<br />
<br />
37Q: Is PHP compiled or Interpreted language<br />
<br />
Ans: php interpreted language.<br />
<br />
38Q: Is php supports multiple Databases<br />
<br />
Ans: yes<br />
<br />
39Q: PHP stands for?<br />
<br />
Ans: hyper text pre processer<br />
<br />
40Q: Which function used to get the current time in mysql?<br />
Ans: getTime()<br />
<br />
41Q: To remove duplicate rows from the result set of a SELECT use the following keyword:<br />
<br />
Ans: DISTINCT<br />
<br />
42Q: What are default session time and path?<br />
Ans: default session time in PHP is 1440 seconds or 24 minutes<br />
Default session save path id temporary folder /tmp<br />
<br />
43Q: how to track no of user logged in ?<br />
Ans: whenever a user logs in track the IP, userID etc..and store it in a DB with a active flag while log out or sesion expire make it inactive. At any time by <br />
<br />
counting the no: of active records we can get the no: of visitors.<br />
<br />
44Q: what is difference between explode implode?<br />
<br />
Ans: explode function:-it breaks a string into array.<br />
<?php<br />
$str="hello world.it's a beautiful day.":<br />
print_r(explode(" ",$str):// space between two double quotes should be there otherwise it shows Warning: explode() [function.explode]: Empty delimiter in D:\www<br />
<br />
\vhosts\localhost\test\setupTest.php on line 29<br />
?><br />
ans-ARRAY<br />
[0]=>hello<br />
[1]=>world.<br />
[2]=>it's<br />
[3]=>a<br />
[4]=>beautiful<br />
[5]=>day.<br />
<br />
implode:-returns a string from elements of an array.<br />
<?php<br />
$arr=array('hello','world!',beautiful,'day!');<br />
echo implode(" ",$arr);<br />
?><br />
ans-hello world! beautiful day!<br />
<br />
<br />
45Q: Will comparison of string "10" and integer 11 work in PHP?<br />
<br />
Ans: Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.<br />
<br />
46Q: what is terinary opertion in php?<br />
<br />
ans- It is called the ternary operator because it takes three operands - a condition, a result for true, and a result for false.<br />
<br />
OR<br />
<br />
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.<br />
<br />
<?php<br />
$agestr = ($age < 18) ? 'child' : 'adult';<br />
?><br />
<br />
47Q: explain two types of arraay sort.<br />
<br />
Ans: sort()->sort the array value alphabetically, but not maintaining the index.<br />
asort()->sort the array value alphabetically, and also maintaining the index.<br />
arsort()->sort the array value alphabetically in reverse order and also maintaining the index.<br />
<br />
ksort()->sort the array according to key.<br />
krsort()->sort the array according to key in the reverse order.<br />
<br />
48Q: how can u know size of array?<br />
<br />
Ans: The sizeof() function counts the elements of an array, or the properties of an object.<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>This function is an alias of the count() function.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$a = array(1,2,2,<br />
array(1,1));<br />
echo sizeof($a);// 4<br />
echo sizeof($a[1]);// 1<br />
echo sizeof($a[3]);// 2<br />
<br />
49Q: Number of argument in a function,How can u know?<br />
<br />
Ans: func_num_args() function returns the number of parameters passed in.<br />
<br />
50Q: how can u get current date and time?<br />
<br />
Ans: date('r');<br />
<br />
51Q: How can u et ip address of asystem?<br />
<br />
Ans: $_SERVER['SERVER_ADDR'];<br />
<br />
$_SERVER['REMOTE_ADDR'];<br />
<br />
52Q: What is Isset()?<br />
<br />
Ans: isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false<br />
<br />
otherwise, or if the variable is set to the value NULL.<br />
<br />
53Q: what is difference between __sleep and __wakeup()?<br />
<br />
Ans: __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.<br />
<br />
54Q: How many way you can get a date from mysql?<br />
<br />
ans: SELECT CURDATE();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SELECT CURRENT_DATE();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SELECT CURTIME();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SELECT CURRENT_TIME();<br />
<br />
55Q: what are the joins in mysql and what are they?<br />
<br />
Ans: Different types of joins are ----<br />
<br />
1.JOIN(Inner Join): Return rows when there is at least one match in both tables<br />
2.LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table<br />
3.RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table<br />
4.FULL JOIN: Return rows when there is a match in one of the tables<br />
<br />
56Q: what is normalisation ?<br />
<br />
Ans: The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed).<br />
<br />
First Normal Form<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, <br />
<br />
and that every column stores the least amount of information possible (making the field atomic).<br />
<br />
Second Normal Form<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form.<br />
<br />
Third Normal Form<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
the primary key, but dependant on another value in the table<br />
<br />
57Q: What is the maximum length of a table name, a database name, or a field name in MySQL?<br />
<br />
Ans: Database name: 64 characters<br />
Table name: 64 characters<br />
Column name: 64 characters<br />
<br />
58Q: list of php CMS?<br />
<br />
Ans: Drupal, Joomla, PhpBB, Wordpress.<br />
<br />
59Q: list of frameworks in php ?<br />
<br />
Ans: Zend,CodeIgniter and CackePHP framework.<br />
<br />
60Q: Difference between CMS and Framework.<br />
<br />
Ans: An application framework is something which we use to build our web application on, I mean we use the framework provided classes, events, methods and create an <br />
<br />
application.<br />
<br />
A CMS is already a developed application with a set of features, however most of them are coded in such a way that users can tweak them around and modify the code<br />
<br />
to fit their own needs.<br />
<br />
So a framework does not come with a working application, but a CMS comes with one.<br />
<br />
61Q: Http is stateless or stateful?<br />
<br />
Ans: stateless.<br />
<br />
62Q: Max execution time?<br />
<br />
Ans: 30sec.<br />
<br />
63Q: Max uploading size?<br />
<br />
Ans: 2Mb<br />
<br />
64Q: How session starts?<br />
<br />
Ans: session_start()<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-57186315494592602392014-04-02T23:13:00.001-07:002014-07-12T05:38:12.407-07:00drupal interview questions and answers for 2 years experience<div dir="ltr" style="text-align: left;" trbidi="on">
drupal interview questions and answers for 2 years experience<br />
<span style="color: red;">Compare Joomla and Drupal Terminology</span><br />
<br />
Joomla Template is called Theme in Drupal.<br />
Component = Module.<br />
Module = Block.<br />
Mambot/Plugin = Input filter.<br />
Menu-Horizontal = Primary Links<br />
Menu-Vertical = Navigation<br />
Dynamic Content Item = Story<br />
Static Content = Page<br />
Back-end = there is no back-end in Drupal,<br />
SEF = Clean URLs (but some docs refer to SEF, too).<br />
Section = Taxonomy Vocabulary/Term<br />
Section Title = Taxonomy Term (master)<br />
Category = Taxonomy Term (child)<br />
Introtext = Teaser<br />
Maintext = Body (see explanation below)<br />
Pathway = Breadcrumb<br />
Q: Drupal current version ?<br />
Answer:- The Drupal current varsion is 7.21<br />
<br />
Q:What is Drupal ?<br />
Drupal is an open-source platform and content management system for building dynamic web sites offering a broad range of<br />
<br />
features and services including user administration, publishing workflow, discussion capabilities, news aggregation,<br />
<br />
metadata functionalities using controlled vocabularies and XML publishing for content sharing purposes.<br />
<br />
Q: drupal basic Topics?<br />
Answer:- Node, Module, Teaser, theme, Path, taxonomy, Patch, Region, Block, Menu<br />
<br />
Q. How do I access the Drupal admin panel, when the login block is disabled?<br />
Answer :-http://yoursitename.com/?q=user<br />
are if we are using clean url<br />
the url is http://yoursitename.com/user<br />
<br />
Q: explain the block in drupal?<br />
Answer: Block are the boxes of content. that can be dispay in header, siderbar, main body, footer (regions)<br />
<br />
Get Block content in drupal7<br />
<br />
Answer: <?php<br />
<br />
$block = module_invoke('views', 'block_view', 'map-block_1');<br />
print $block['content'];<br />
<br />
?><br />
<br />
Compare Joomla and Drupal Terminology<br />
Bolck are called module in joomla.<br />
<br />
Q: What is a Box in Drupal?<br />
Answer: Box is a simple Block(add the boxes module to display boxes).<br />
<br />
Q: What is a comment in drupal?<br />
Answer: the comment module allows user to comment the articles and pages and blocks.<br />
<br />
Q: what is a node in drupal?<br />
Answer: A node is a single entry that uses some content type poll, page, story, and etc submission form.<br />
<br />
Q: how to put it into maintenance mode in drupal?<br />
Answer:Go to "Configuration" ->"Maintenance mode".<br />
Make sure the "Put site into maintenance mode" box is checked.<br />
Enter the message you want visitors to see during the interruption.<br />
Click "Save configuration".<br />
<br />
Q:How do you handle upgrades?<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step:1 backing up the site,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step2: putting it into maintenance mode<br />
Step3: downloading the new version of the module<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step4: uncompressing it<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step5: running update.php<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step6: testing the site<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Step7: taking the site out of maintenance mod<br />
<br />
List the modules required for building a social networking website in Drupal.<br />
• Activity<br />
• Advanced Forum<br />
• Advanced Profile Kit<br />
• Application Toolbar (Appbar)<br />
• Author Pane<br />
• Buddylist2 Package<br />
• Buddylist: list your social network<br />
• CiviCRM: manage community contacts, relationships, and activities<br />
• CiviNode and CiviNode CCK: Tools For Integrating CiviCRM Contacts Into Drupal Content<br />
• Comment Notify<br />
• FOAF: friends of a friend<br />
• Facebook-style Statuses<br />
• Family: Record, display, and analyze genealogical data.<br />
• Flag Friend<br />
• Friend<br />
• FriendList<br />
• Front: Show group membership and events<br />
• Gigya Socialize Module<br />
• Invite: send invitations to join your site<br />
• Notice Feed<br />
• Organic Group<br />
• Profile Setup<br />
• Radioactivity<br />
• Sports Pickem<br />
• Tellafriend Node<br />
• User Invite<br />
• User Relationships<br />
• UserTag:Tag users with taxonomy terms<br />
• meetü: The Social Networking Game from the OPL @ RIT<br />
<br />
Q: List the SEO modules available in Drupal.<br />
Pathauto<br />
Nodewords/ Meta tags<br />
Service links<br />
Google analytics<br />
Related Links<br />
Search 404<br />
Site map<br />
Url list<br />
<br /></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-64684911224094766692014-03-28T23:20:00.001-07:002014-03-28T23:20:58.233-07:00how to get the first 500 record from table in php mysql mysql<div dir="ltr" style="text-align: left;" trbidi="on">
we are geting first 500 record form table using php and mysql<br />
<br />
mysql_connect("hostname", "username","")<br />
mysql_select_db("databasename");<br />
<br />
$sql = "SELECT * FROM table ORDER BY id DESC LIMIT 50";<br />
$result = mysql_query($sql);<br />
<br />
while ($query = mysql_fetch_assoc($result))<br />
<br />
<br />
<br />
{<br />
<br />
echo "$query[fieldname1] $query[fieldname2] <br/>";<br />
}</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-79811432274843921442014-03-27T22:37:00.002-07:002014-03-27T22:37:38.754-07:00find visitor location php<div dir="ltr" style="text-align: left;" trbidi="on">
<?php<br />
function geoCheckIP($ip)<br />
<br />
{<br />
<br />
//check, if the provided ip is valid<br />
<br />
if(!filter_var($ip, FILTER_VALIDATE_IP))<br />
<br />
{<br />
<br />
throw new InvalidArgumentException("IP is not valid");<br />
<br />
}<br />
<br />
//contact ip-server<br />
<br />
$response=@file_get_contents('http://www.netip.de/search?query='.$ip);<br />
<br />
if (empty($response))<br />
<br />
{<br />
<br />
throw new InvalidArgumentException("Error contacting Geo-IP-Server");<br />
<br />
}<br />
<br />
//Array containing all regex-patterns necessary to extract ip-geoinfo from page<br />
<br />
$patterns=array();<br />
<br />
$patterns["domain"] = '#Domain: (.*?)&nbsp;#i';<br />
<br />
$patterns["country"] = '#Country: (.*?)&nbsp;#i';<br />
<br />
$patterns["state"] = '#State/Region: (.*?)<br#i';<br />
<br />
$patterns["town"] = '#City: (.*?)<br#i';<br />
<br />
//Array where results will be stored<br />
<br />
$ipInfo=array();<br />
<br />
// &nbsp;<br />
<br />
//check response from ipserver for above patterns<br />
<br />
foreach ($patterns as $key => $pattern)<br />
<br />
{<br />
<br />
//store the result in array<br />
<br />
$ipInfo[$key] = preg_match($pattern,$response,$value) && !empty($value[1]) ? $value[1] : 'not found';<br />
<br />
}<br />
/*I've included the substr function for Country to exclude the abbreviation (UK, US, etc..)<br />
To use the country abbreviation, simply modify the substr statement to:<br />
substr($ipInfo["country"], 0, 3)<br />
*/<br />
$ipdata = $ipInfo["town"]. ", ".$ipInfo["state"].", ".substr($ipInfo["country"], 4);<br />
<br />
return $ipdata;<br />
<br />
}<br />
$ip = '';<br />
/*<br />
<br />
<br />
echo geoCheckIP($ip);*/<br />
//echo $ip = $_SERVER['REMOTE_ADDR'];<br />
$ram = geoCheckIP($ip);<br />
echo $ram;<br />
?></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-61429811764169185342014-03-27T22:36:00.001-07:002014-03-27T22:36:57.982-07:00how to get google map coordinates by address in php <div dir="ltr" style="text-align: left;" trbidi="on">
<?php<br />
function getCoordinates($address){<br />
<br />
$address = str_replace(" ", "+", $address); // replace all the white space with "+" sign to match with google search pattern<br />
<br />
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";<br />
<br />
$response = file_get_contents($url);<br />
<br />
$json = json_decode($response,TRUE); //generate array object from the response from the web<br />
<br />
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);<br />
<br />
}<br />
echo getCoordinates('Hyderabad, Andhra Pradesh, India');<br />
?></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-61452854768740208322014-03-24T03:30:00.002-07:002014-03-24T03:30:20.988-07:00How to check if value exists in a database or not?<div dir="ltr" style="text-align: left;" trbidi="on">
How to check if value exists in a database or not<br />
<br />
$result = mysql_query("SELECT id FROM mytable WHERE city = 'c7'");<br />
if(mysql_num_rows($result) == 0) {<br />
// row not found, do stuff...<br />
} else {<br />
// do other stuff...<br />
}</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-68220863718137696472014-03-20T22:50:00.001-07:002014-03-20T22:50:28.415-07:00wordpress author related taxonomy posts <div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="color: blue;">wordpress author related taxonomy posts</span></b><span class="Apple-tab-span" style="white-space: pre;"><b><span style="color: blue;"> </span></b> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><?php<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>global $post;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$author_id=$post->post_author;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$args = array(<br />
'post_type' => 'deals',<br />
'author'=> $author_id<br />
);<br />
<br />
$the_query = new WP_Query( $args );<br />
<br />
if ( $the_query->have_posts() ) :<br />
<br />
while ( $the_query->have_posts() ) : $the_query->the_post();<br />
<br />
the_title();<br />
<br />
endwhile;<br />
<br />
//wp_reset_query();<br />
endif;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>?></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-17767465666075311292014-03-19T06:03:00.005-07:002014-03-19T06:03:48.965-07:00how to get difference between two dates in php<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
how to get difference between two dates in php<br />
<br />
<span style="color: blue;"><?php</span><br />
<span style="color: blue;">$date1 = new DateTime("2006-09-07");</span><br />
<span style="color: blue;">$date2 = new DateTime("2014-03-19");</span><br />
<span style="color: blue;">$interval = $date1->diff($date2);</span><br />
<span style="color: blue;">echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";</span><br />
<span style="color: blue;">?></span><br />
<br />
<span style="color: red;">Output</span>: <span style="color: blue;">difference 7 years, 6 months, 12 days</span></div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-11596231035544297502014-03-19T04:53:00.001-07:002014-03-19T04:53:18.610-07:00wordpress update query example<div dir="ltr" style="text-align: left;" trbidi="on">
wordpress update query example<br />
<br />
$sql = "UPDATE `dbname`.`wp_terms` SET `slug` = REPLACE(`slug`, \'--\', \'-\') WHERE `slug` LIKE \'%--%\' COLLATE utf8_bin";</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-3426481533468304180.post-55271891970578352172014-02-20T00:13:00.001-08:002014-02-20T00:13:55.425-08:00Get Post or Page Content By Id wordpress<div dir="ltr" style="text-align: left;" trbidi="on">
Get Post or Page Content By Id wordpress<br />
<br />
<?php<br />
<br />
$page_id = 7;<br />
<br />
$page_data = get_page( $page_id );<br />
<br />
$excerpt = apply_filters('the_excerpt', $page_data->post_content); <br />
<br />
$title = $page_data->post_title;<br />
<br />
$permalink = get_permalink($page_id);<br />
<br />
echo '<h2>' . $title . '</h2>'; <br />
echo $excerpt . '<br/>'; <br />
echo '<a href="' . $permalink . '">Read more</a>';<br />
?></div>
Unknownnoreply@blogger.com