1

I did my research but can't find any topic or example on how to include an php file in the header and calling an function from the include in the body of html.

the examples all show how to include an function in the head.

what I understand is this.

<script type="text/php" src="test.php"></script>

in the test.php i have a function testing with echo 'test' and not using the php tags.

Could someone post an small example how to include php in tidesdk and echo it in the body ?

I have PHP enabled in the app config.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • the problem is including php in an TIDESDK app, I can't get it to work – Alex Planting Apr 04 '13 at 20:46
  • You should learn about php first. PHP is a server side scripting language – hek2mgl Apr 04 '13 at 20:49
  • This is what i am trying to do, I am familiar with PHP but not how to set it up properly in: http://tidesdk.multipart.net/docs/user-dev/generated/#!/guide/using_php – Alex Planting Apr 04 '13 at 20:51
  • This is new to me. Sorry. Unfortunately I've never used it before. – hek2mgl Apr 04 '13 at 20:53
  • found it after trying 100 times different methodes but finally found out how it works. include php as src file, with jquery I assigned an variable to the php function and then replaced html of an div. – Alex Planting Apr 05 '13 at 06:55

4 Answers4

3

@hek2mgl Hello. You will find a recent tutorial in German here that should illustrate this for you.

http://www.phpgangsta.de/mit-tidesdk-und-webtechniken-konnen-wir-desktop-applikationen-bauen

An older but relevant second tutorial is here:

http://www.sanisoft.com/blog/2011/01/03/introduction-to-creating-desktop-applications-with-php-and-titanium

fairwinds
  • 2,133
  • 12
  • 21
  • While this answer may theoretically answer the question, [it is better](http://meta.stackexchange.com/q/8259) to include the essential parts of the links here, and provide the links for reference. – hichris123 Feb 23 '14 at 03:44
1

Here is what I changed in example hello world of tidesdk to make it work.

  1. Changed in manifest: app://index.html to index.php
  2. Added <?php echo "test"; ?> to the page
  3. Turned on PHP

After this, it worked.

Alexander
  • 2,320
  • 2
  • 25
  • 33
Zaheer
  • 221
  • 1
  • 3
0

First of all, you have to forget you are using PHP as a server side language for rendering pages and sending responses to the clients. In TideSDK, PHP can be used as a replacement of Javascript (as Ruby or Python), meaning echo will probably will just do the same as console.log for JS.

Your php file will have to deal with the DOM and Events just like any other javascript file does, in the end, your solution of replacing the content of a DIV with jQuery and your script works as expected, you can use complete JS frameworks like Knockout with the help of your PHP scripts. This link will give you more examples to exploit the functionality.

https://github.com/TideSDK/TideSDK/wiki/Using-TideSDK-with-PHP

Phrozen
  • 559
  • 4
  • 13
0

I'm just grappling with TideSDK myself, and I think I got it:

Per my 10th reading of the Guide to using PHP in TideSDK...

PHP Preprocessing - the stuff that makes it "similar to PHP code on an Apache server", with "script contents replaced with the script output before the content is rendered by the browser" - only happens if:

  1. your external PHP code is surrounded by <?php and ?> tags
  2. it's in a file with the .php extension
  3. if used as an include, it must be referenced via the include or require commands, rather than

If you do use the <script type="text/php" src=""... method for including files, the included .php file must not be enclosed by <?php and ?>. Sort of a weird system, eh?

yl3
  • 21
  • 5