26 May 2009

PHP Theory

  • # For printing out strings, there are echo, print and printf. Explain the differences. - echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:



and it will output the string "Welcome to TechInterviews!" print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf.


  • # chunk_split
echo chunk_split("My name is Jankit P Shah", 2, "
");
It will give output like:
My
n
am
e
is
J
an
ki
t
P
Sh
ah


  • # What’s the difference between htmlentities() and htmlspecialchars()? - htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.

  • Difference between for and foreach?
    'For' is used to execute a loop of any n number of time
    'Foreach' is used to execute a loop of each and every element of an array

  • How can I execute a php script using command line?

    Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, “php myScript.php”, assuming “php” is the command to invoke the CLI program.
    Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

  • What is the difference between var_dump and print_r?
    var_dump will give output of each element of an array with its size and type.
    print_r is used only to print the element of an array

  • Name of PHP function which can create runtime variables for the index of each array.

    $size = "large";
    $var_array = array("color" => "blue",
    "size" => "medium",
    "shape" => "sphere");
    extract($var_array, EXTR_PREFIX_SAME, "wddx");//here prefix "wddx" will be added if any same name of variable is already set

  • What are the different types of errors in php?

    Three are three types of errors:
    1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.
    2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
    3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behaviour is to display them to the user when they take place.

  • Joomla- what are the difference of module, extension and plugin?

    Components

    A component is in fact a seperate application. You can think of a component as something that has it's own functionality, it's own database and it's own presentation. So if you install a component, you add an application to your website. Examples of components are a forum, a newsletter, a community system, a photo gallery, etc. You could think of all of these as being a seperate application. Everyone of these would make perfectly sence as a stand-alone system. A component will be shown in the main part of your website and only one component will be shown. A menu is then in fact nothing more then a switch between different components. You can compare it a bit with your windows taskbar, where you see a tab for each open application.

    Modules

    Modules are extensions which present certain pieces of information on your site. It's a way of presenting information that is already present. This can add a new function to an application which was already part of your website. Think about latest article modules, login module, a menu, ... . Typically you'll have a number of modules on each web page. The difference between a component and a module is not always very clear for everybody. But if you think about it, it's really not that difficult. A module doesn't make sense as a standalone application, it will just present information or add a function to an existing application. Take a newsletter for instance. A newsletter is a component. You can have a website which is used as a newsletter only. That makes perfectly sense. Although a newsletter component probably will have a subscription page integrated, you might want to add a subscription module on a sidebar on every page of your website. You can put this subscribe module anywhere on your site. You'll probably agree with me that a site with just a subscription module and no actual newsletter component would be rather ridiculous.

    Plugins

    They used to be called mambots in Joomla 1.0.x, but since Joomla 1.5.x they're called plugins. A plugin is a function which is performed on a part of Joomla before this part is shown. This part can be on content, on the editor, on the complete system, etc. This might seem a bit abstract, but you'll understand it with an example. Let's take one of the plugins of Ulti Joomla as an example. This is a plugin which can make a reflection of the images you use in your content articles.


JavaScript Interview Questions


  • # What are JavaScript types? - Number, String, Boolean, Function, Object, Null, Undefined.

  • # How do you convert numbers between different bases in JavaScript? - Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);

  • # What does isNaN function do? - Return true if the argument is not a number.

  • # What boolean operators does JavaScript support? - &&, || and !

  • # What does "1"+2+4 evaluate to? - Since 1 is a string, everything is a string, so the result is 124.

  • # How about 2+5+"8"? - Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.

  • # What looping structures are there in JavaScript? - for, while, do-while loops, but no foreach.

  • # How do you create a new object in JavaScript? - var obj = new Object(); or var obj = {};

  • # How do you assign object properties? - obj["age"] = 17 or obj.age = 17.

  • # What’s a way to append a value to an array? - arr[arr.length] = value;

  • # What is this keyword? - It refers to the current object.

XML Interview Questions

  • What is the difference between Schema and DTD?

    Ans:

    A DTD is:

    The XML Document Type Declaration contains or points to markup declarations that provide a grammar for a class of documents. This grammar is known as a document type definition or DTD.

    The DTD can point to an external subset containing markup declarations, or can contain the markup declarations directly in an internal subset, or can even do both.

    A Schema is:

    XML Schemas express shared vocabularies and allow machines to carry out rules made by people. They provide a means for defining the structure, content and semantics of XML documents.

    In summary, schemas are a richer and more powerful of describing information than what is possible with DTDs.

  • What are the steps to transform XML into HTML using XSL?

    Ans: XSLT - a language for transforming XML documents

    XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element.

  • What is the difference between XML and HTML?

    Ans:

    1.HTML is presentaton language where as XML is not either a programing language or a presentation language. It is used to transfer data between applications and databases.

    2.HTML is not case-sensitive where as XML is case-sensitive.

    3.In XML we can define our own tags as it is not possible in HTML.

    4.In XML it is mandatory to close each and every tag where as in HTML it is not required.

    5.XML describes the data where as HTML only defines the data.

  • Coming later ....

22 May 2009

Proposals: How Much is Too Much?

njwebwiz asks a question in the forums regarding how much time and effort should be put into winning a web development project. He's asking because he spent 13 hours trying to win a project only to lose out at the last minute.

I feel your pain. We missed a job last year after spending a massive amount of time doing exactly what you did and I was a whole lot grumpier than you seem to be!

After a conversation with my brother (he runs a decent-sized landscaping business) I felt a whole lot better. You see, in other industries, 13 hours putting together a proposal is considered hardly any time at all. My brother employs a full-time estimator to put proposals together.

With web projects there's no right answer of course, aside from "Whatever it takes to make a profit."

If it's a $50,000 project, then 13 hours to put the proposal together is a short amount of time. For a $1,000 project, 13 hours on a speculative quote makes no sense.

This could have been a waste of 13 hours work on njwebwiz's part, but he's turned it into a learning experience and understands his business a little better.

He has learned about major influencing factors (he lost some credibility with the prospect because he's without a web site) and he'll almost certainly commit far less time and energy to speculative quotes in the future.

He goes on to say in the post, "I realize that I can't respond to potential clients with, 'You have to pay me a $250 retainer before I'll even discuss your project with you'."

Actually njwebwiz, you can.

I've done this on more than one occasion when a new prospect has asked for a quote. I pitch it this way: We can do this two ways; you tell me exactly what you want your web site to look like and do and I'll quote, or I'll take the time to figure out the smartest approach, research how it is best developed, assess your competitors, and so on for an initial fee."

I've charged $500 for that review and, unsurprisingly, every prospect who said "Yes" then went ahead with the full proposal (probably to avoid feeling as though they wasted that first $500).

Web design is vastly different to landscaping -- there's no set area of turf to lay or trees to plant. Much of the value that we all provide as web developers is because we bring different experiences, knowledge, expertise, and more to each project -- and what we know and research can make the difference between a successful site or not.

14 May 2009

Dummy Credit Card Numbers for Testing

Here is a list of dummy credit card number that can be used while testing your applications involving credit card transactions:

Visa: 4111-1111-1111-1111

MasterCard: 5431-1111-1111-1111

Amex: 341-1111-1111-1111

Discover: 6011-6011-6011-6611

Credit Card Prefix Numbers:

Visa: 13 or 16 numbers starting with 4

MasterCard: 16 numbers starting with 5

Discover: 16 numbers starting with 6011

AMEX: 15 numbers starting with 34 or 37

13 May 2009

MySQL - Function name: FIND_IN_SET

Function name: FIND_IN_SET
Aliases: -
Function type: String function
Purpose: Return position of value in string of comma-separated values

Description: FIND_IN_SET() looks for the first occurrence of a string within another string containing comma-separated values:

FIND_IN_SET('r','c,a,r,s,t,e,n, ,p,e,d,e,r,s,e,n') => 3

Usage example: Suppose I have a table of vehicle types and colors, representing the available color range for vehicles in my shop. No type/color combination can appear more than once, so the primary key spans (type, color). It holds the following data:

mysql> select * from vehicle_colors;
+------+-------+
| type | color |
+------+-------+
| bike | blue |
| bike | green |
| suv | blue |
| van | green |
+------+-------+

If I want to know

* the vehicles that are available in either blue or green
* whether they are available in blue or green or both

I can get this information with a single query like so:

SELECT type, SUM(FIND_IN_SET(color, 'blue,green')) AS which_colors
FROM vehicle_colors
WHERE color IN ('blue', 'green')

GROUP BY type;
+------+--------------+
| type | which_colors |
+------+--------------+
| bike | 3 |
| suv | 1 |
| van | 2 |
+------+--------------+

The output tells me that bikes, suvs and vans may all be found in either blue or green (the fact that they are listed at all) and that bikes are available in both colors (1+2=3), suvs in blue only (1) and vans in green only (2).

08 May 2009

Different ways to create or convert to PDF files

Q: First things first - How do I create PDF documents on my computer
without Adobe Acrobat?

A: Get a copy of DoPDF - it installs as a virtual printer driver on
your desktop just like Acrobat and lets you print PDF files from any
Windows application including images, documents, emails, websites,
etc.

Q: I don’t want to install software just for converting a bunch of
documents to PDF. Do you know of any alternative?

A: Upload your documents to Google Docs via the browser and then
export them as PDF files. Simple.

Q: A client just sent me a PowerPoint presentation by email. Since I
am travelling without the laptop and my mobile phone cannot read PPT
files, what should I do?

A: Forward that email message (with the PPT attachment) to
pdf@koolwire.com - they’ll convert the presentation to PDF and email
it back to you immediately. Most smartphones and web enabled mobile
phones can read PDF files.

Q: How do I directly save a web page as PDF without having to save
that page as an HTML file first?

A: Go to PrimoPDF, type the URL of the web page and they’ll send you a
PDF version of that page via email.

Q: How can I convert PDF files into other formats like Word documents,
images, HTML web pages, etc.

A: You can upload the PDF document to Zamzar and convert it any
formats like doc, html, png, txt or rtf (rich text format).
Alternatively, you can convert PDF to HTML using Gmail.

Q: How do I create a single PDF package by merging files of different
formats.

A: Try Loop PDF - it’s a free service that lets you combine multiple
documents, images and even web pages into a single PDF file.

Q: How do I merge two or more PDF files into one? Can I also change
the page order?

A: You can grab PDF Fill - it’s a versatility PDF editing tool that
lets you combine PDFs from the desktop. PDF Fill can also help you
rearrange pages in any order or for rotating pages inside a PDF.

Q: I want to extract some text from a PDF and use it in my Word
document. What is the best option?

A: Go to PDFTextOnline and upload your PDF - it will extract text from
the first 10 pages of your PDF document (to start) and will also show
the PDF bookmarks, document properties, and form data (if available).

Q: I can’t get the above trick to work since I have a scanned PDF.

A: You can extract text from scanned PDF documents with Google Search.
It’s not an instant process but probably the only free solution we
know of.

Q: I have some restricted PDF documents on my computer in the sense
that they neither allow printing nor can you select text with the
mouse.

A: Get the PDF Unlocker - its a free Windows utility that will remove
all common restrictions around a PDF file without requiring any
passwords. Alternatively, you may use the online service at
ensode.net that will remove all the printing or copying/pasting
related restrictions from your PDF.

Q: Some PDF files on our company’s intranet are protected by a
password that no one can remember anymore. Can we still open them?

A: Check this article - How to Open Password Protected PDF

Q: I am looking for a service that would let visitors download my
articles as PDF files.

A: Add the Web2PDF button anywhere in your website - it converts web
pages to PDF files on demand and also keeps a track of all PDF
conversion related activities on your website.

Q: Someone sent me a PDF document in Chinese but I can read only
English?

A: You can easily translate PDF files using Google Translate and Zoho
Viewer.

Q: How can I add annotations or text notes to some of my PDF
documents?

A: Get the PDF-X Viewer - it’s like Adobe Reader but with some extra
features. You can add comments, annotations or even paste images to
your PDF pages. You can also add annotations, call-outs and text to
your PDFs online with PDF Escape.

Q: How do I read PDF files online without desktop software?

A: You can open PDF documents in the browser with PDFMeNot without
requiring any software. See more options.

Q: Can I fill PDF forms online without Acrobat Reader?

A: Sure, go to PDF Filler, upload the PDF form and start typing. PDF
typewriter works by converting PDF forms into images and allowing the
user to type right on top of the images.

Q: How can I add watermarks or even my (real) signature to a PDF
document?

A: First draw your signature in Paint (or other photo editing tool)
and save it as an image. Make sure you crop all the blank portion that
lies outside the signature. Now open the PDF document inside PDF-X
Viewer and copy-paste that watermark / signature image. Simple.

Q: I have a PDF book that contains some 200 pages. Is there a way to
extract selected pages from that book and save it as another PDF.

A: You can either PDF Merge or PDF SAM (split and merge) to extract
pages from a PDF document.

Q: How can I protect my PDF documents with a password?

A: Upload your PDF file to PDF Hammer, set a security password and
export it as PDF again.

Q: A PDF document has lot of links but I can’t click them as they are
in plain text. How do I make them clickable?

A: Go to PDF Escape, upload the PDF and then place hyperlinks anywhere
on the page.

Q: Which online service(s) would you recommend for uploading PDF files
on the web?

A: My favorite is Issuu - they have built an excellent PDF viewer
inside a beautiful interface. You can also use Issuu to embed PDF
files in your own website. Next recommendation is Scribd - it’s a more
popular service so your PDF document would get more eye balls.

04 May 2009

Google like Password strength checker



Google style password strenth meter





Google style password strength meter













Password